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
|
||||
if l.r != nil {
|
||||
if b, _ := l.r.CommitIDBehind(); b {
|
||||
return ErrWriteInROnly
|
||||
}
|
||||
|
||||
var rl *rpl.Log
|
||||
if rl, err = l.r.Log(g.Data()); err != nil {
|
||||
log.Fatal("write wal error %s", err.Error())
|
||||
|
|
|
@ -124,6 +124,8 @@ func (r *Replication) Log(data []byte) (*Log, error) {
|
|||
commitId := r.commitID
|
||||
if lastID < commitId {
|
||||
lastID = commitId
|
||||
} else if lastID > commitId {
|
||||
return nil, ErrCommitIDBehind
|
||||
}
|
||||
|
||||
l := new(Log)
|
||||
|
|
|
@ -9,9 +9,10 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrLogNotFound = errors.New("log not found")
|
||||
ErrStoreLogID = errors.New("log id is less")
|
||||
ErrNoBehindLog = errors.New("no behind commit log")
|
||||
ErrLogNotFound = errors.New("log not found")
|
||||
ErrStoreLogID = errors.New("log id is less")
|
||||
ErrNoBehindLog = errors.New("no behind commit log")
|
||||
ErrCommitIDBehind = errors.New("commit id is behind last log id")
|
||||
)
|
||||
|
||||
type LogStore interface {
|
||||
|
|
Loading…
Reference in New Issue