etcdserver: check invalid range in txn

This commit is contained in:
Xiang Li
2016-01-25 18:39:08 -08:00
parent b1a45fe1c8
commit 128b5e7387
4 changed files with 84 additions and 18 deletions

View File

@ -24,6 +24,11 @@ type KV interface {
// Rev returns the current revision of the KV.
Rev() int64
// FirstRev returns the first revision of the KV.
// After a compaction, the first revision increases to the compaction
// revision.
FirstRev() int64
// Range gets the keys in the range at rangeRev.
// If rangeRev <=0, range gets the keys at currentRev.
// If `end` is nil, the request returns the key.

View File

@ -106,6 +106,13 @@ func (s *store) Rev() int64 {
return s.currentRev.main
}
func (s *store) FirstRev() int64 {
s.mu.Lock()
defer s.mu.Unlock()
return s.compactMainRev
}
func (s *store) Put(key, value []byte, lease lease.LeaseID) int64 {
id := s.TxnBegin()
s.put(key, value, lease)