adjust readonly check

This commit is contained in:
siddontang 2014-11-14 16:00:03 +08:00
parent 10a367f978
commit 5196e211cc
1 changed files with 5 additions and 1 deletions

View File

@ -18,7 +18,7 @@ type batch struct {
} }
func (b *batch) Commit() error { func (b *batch) Commit() error {
if b.l.IsReadOnly() { if b.l.cfg.GetReadonly() {
return ErrWriteInROnly return ErrWriteInROnly
} }
@ -104,6 +104,10 @@ 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())