From 9960651c3fd7cb3e7da1e2dedc3f571a73c6873f Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Sat, 22 Aug 2015 17:30:59 -0700 Subject: [PATCH] storage: let range work in the process of txn range should work in the process of txn to help check the status during the txn. --- storage/kvstore.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/storage/kvstore.go b/storage/kvstore.go index 3f958a25d..97d8edfe8 100644 --- a/storage/kvstore.go +++ b/storage/kvstore.go @@ -259,14 +259,16 @@ func (a *store) Equal(b *store) bool { // range is a keyword in Go, add Keys suffix. func (s *store) rangeKeys(key, end []byte, limit, rangeRev int64) (kvs []storagepb.KeyValue, rev int64, err error) { - if rangeRev > s.currentRev.main { + curRev := int64(s.currentRev.main) + if s.currentRev.sub > 0 { + curRev += 1 + } + + if rangeRev > curRev { return nil, s.currentRev.main, ErrFutureRev } if rangeRev <= 0 { - rev = int64(s.currentRev.main) - if s.currentRev.sub > 0 { - rev += 1 - } + rev = curRev } else { rev = rangeRev }