rpl optimize

This commit is contained in:
siddontang 2014-11-18 17:50:22 +08:00
parent 8ab0b84cc2
commit b7cabcbb5f
3 changed files with 6 additions and 7 deletions

View File

@ -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())

View File

@ -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)

View File

@ -12,6 +12,7 @@ var (
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 {