forked from mirror/ledisdb
rpl optimize
This commit is contained in:
parent
8ab0b84cc2
commit
b7cabcbb5f
|
@ -104,10 +104,6 @@ func (l *Ledis) handleCommit(g commitDataGetter, c commiter) error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if l.r != nil {
|
if l.r != nil {
|
||||||
if b, _ := l.r.CommitIDBehind(); b {
|
|
||||||
return ErrWriteInROnly
|
|
||||||
}
|
|
||||||
|
|
||||||
var rl *rpl.Log
|
var rl *rpl.Log
|
||||||
if rl, err = l.r.Log(g.Data()); err != nil {
|
if rl, err = l.r.Log(g.Data()); err != nil {
|
||||||
log.Fatal("write wal error %s", err.Error())
|
log.Fatal("write wal error %s", err.Error())
|
||||||
|
|
|
@ -124,6 +124,8 @@ func (r *Replication) Log(data []byte) (*Log, error) {
|
||||||
commitId := r.commitID
|
commitId := r.commitID
|
||||||
if lastID < commitId {
|
if lastID < commitId {
|
||||||
lastID = commitId
|
lastID = commitId
|
||||||
|
} else if lastID > commitId {
|
||||||
|
return nil, ErrCommitIDBehind
|
||||||
}
|
}
|
||||||
|
|
||||||
l := new(Log)
|
l := new(Log)
|
||||||
|
|
|
@ -9,9 +9,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrLogNotFound = errors.New("log not found")
|
ErrLogNotFound = errors.New("log not found")
|
||||||
ErrStoreLogID = errors.New("log id is less")
|
ErrStoreLogID = errors.New("log id is less")
|
||||||
ErrNoBehindLog = errors.New("no behind commit log")
|
ErrNoBehindLog = errors.New("no behind commit log")
|
||||||
|
ErrCommitIDBehind = errors.New("commit id is behind last log id")
|
||||||
)
|
)
|
||||||
|
|
||||||
type LogStore interface {
|
type LogStore interface {
|
||||||
|
|
Loading…
Reference in New Issue