mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: do not send v2 sync if ttl keys do not exist
This commit is contained in:
parent
da3b71b531
commit
2f96a68a20
@ -733,7 +733,9 @@ func (s *EtcdServer) run() {
|
||||
plog.Infof("the data-dir used by this member must be removed.")
|
||||
return
|
||||
case <-getSyncC():
|
||||
s.sync(s.Cfg.ReqTimeout())
|
||||
if s.store.HasTTLKeys() {
|
||||
s.sync(s.Cfg.ReqTimeout())
|
||||
}
|
||||
case <-s.stop:
|
||||
return
|
||||
}
|
||||
|
@ -127,6 +127,13 @@ func (s *storeRecorder) DeleteExpiredKeys(cutoff time.Time) {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *storeRecorder) HasTTLKeys() bool {
|
||||
s.Record(testutil.Action{
|
||||
Name: "HasTTLKeys",
|
||||
})
|
||||
return true
|
||||
}
|
||||
|
||||
// errStoreRecorder is a storeRecorder, but returns the given error on
|
||||
// Get, Watch methods.
|
||||
type errStoreRecorder struct {
|
||||
|
@ -61,6 +61,8 @@ type Store interface {
|
||||
|
||||
JsonStats() []byte
|
||||
DeleteExpiredKeys(cutoff time.Time)
|
||||
|
||||
HasTTLKeys() bool
|
||||
}
|
||||
|
||||
type TTLOptionSet struct {
|
||||
@ -778,3 +780,9 @@ func (s *store) JsonStats() []byte {
|
||||
s.Stats.Watchers = uint64(s.WatcherHub.count)
|
||||
return s.Stats.toJson()
|
||||
}
|
||||
|
||||
func (s *store) HasTTLKeys() bool {
|
||||
s.worldLock.RLock()
|
||||
defer s.worldLock.RUnlock()
|
||||
return s.ttlKeyHeap.Len() != 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user