mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
storage: return ErrFutureRev if rev is a future one
This commit is contained in:
parent
94924d04db
commit
93f477944b
@ -24,6 +24,7 @@ var (
|
||||
|
||||
ErrTnxIDMismatch = errors.New("storage: tnx id mismatch")
|
||||
ErrCompacted = errors.New("storage: required reversion has been compacted")
|
||||
ErrFutureRev = errors.New("storage: required reversion is a future reversion")
|
||||
)
|
||||
|
||||
type store struct {
|
||||
@ -240,6 +241,9 @@ 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 {
|
||||
return nil, s.currentRev.main, ErrFutureRev
|
||||
}
|
||||
if rangeRev <= 0 {
|
||||
rev = int64(s.currentRev.main)
|
||||
if s.currentRev.sub > 0 {
|
||||
|
@ -79,6 +79,7 @@ func TestRangeBadRev(t *testing.T) {
|
||||
}{
|
||||
{2, ErrCompacted},
|
||||
{3, ErrCompacted},
|
||||
{4, ErrFutureRev},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
_, _, err := s.Range([]byte("foo"), []byte("foo3"), 0, tt.rev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user