From 5196e211ccae8c792a13a1e97fadf8423b87edaf Mon Sep 17 00:00:00 2001 From: siddontang Date: Fri, 14 Nov 2014 16:00:03 +0800 Subject: [PATCH] adjust readonly check --- ledis/batch.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ledis/batch.go b/ledis/batch.go index 526b4b6..b0d04b9 100644 --- a/ledis/batch.go +++ b/ledis/batch.go @@ -18,7 +18,7 @@ type batch struct { } func (b *batch) Commit() error { - if b.l.IsReadOnly() { + if b.l.cfg.GetReadonly() { return ErrWriteInROnly } @@ -104,6 +104,10 @@ 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())