mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #9281 from yudai/fix_unrestored_watchers
mvcc: restore unsynced watchers
This commit is contained in:
commit
63183f8c18
@ -192,7 +192,7 @@ func (s *watchableStore) Restore(b backend.Backend) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for wa := range s.synced.watchers {
|
for wa := range s.synced.watchers {
|
||||||
s.unsynced.watchers.add(wa)
|
s.unsynced.add(wa)
|
||||||
}
|
}
|
||||||
s.synced = newWatcherGroup()
|
s.synced = newWatcherGroup()
|
||||||
return nil
|
return nil
|
||||||
|
@ -297,6 +297,8 @@ func TestWatchFutureRev(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWatchRestore(t *testing.T) {
|
func TestWatchRestore(t *testing.T) {
|
||||||
|
test := func(delay time.Duration) func(t *testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
b, tmpPath := backend.NewDefaultTmpBackend()
|
b, tmpPath := backend.NewDefaultTmpBackend()
|
||||||
s := newWatchableStore(b, &lease.FakeLessor{}, nil)
|
s := newWatchableStore(b, &lease.FakeLessor{}, nil)
|
||||||
defer cleanup(s, b, tmpPath)
|
defer cleanup(s, b, tmpPath)
|
||||||
@ -312,6 +314,8 @@ func TestWatchRestore(t *testing.T) {
|
|||||||
w := newStore.NewWatchStream()
|
w := newStore.NewWatchStream()
|
||||||
w.Watch(0, testKey, nil, rev-1)
|
w.Watch(0, testKey, nil, rev-1)
|
||||||
|
|
||||||
|
time.Sleep(delay)
|
||||||
|
|
||||||
newStore.Restore(b)
|
newStore.Restore(b)
|
||||||
select {
|
select {
|
||||||
case resp := <-w.Chan():
|
case resp := <-w.Chan():
|
||||||
@ -327,6 +331,11 @@ func TestWatchRestore(t *testing.T) {
|
|||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
t.Fatal("failed to receive event in 1 second.")
|
t.Fatal("failed to receive event in 1 second.")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run("Normal", test(0))
|
||||||
|
t.Run("RunSyncWatchLoopBeforeRestore", test(time.Millisecond*120)) // longer than default waitDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestWatchBatchUnsynced tests batching on unsynced watchers
|
// TestWatchBatchUnsynced tests batching on unsynced watchers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user