Merge pull request #9281 from yudai/fix_unrestored_watchers
mvcc: restore unsynced watchersrelease-3.4
commit
63183f8c18
|
@ -192,7 +192,7 @@ func (s *watchableStore) Restore(b backend.Backend) error {
|
|||
}
|
||||
|
||||
for wa := range s.synced.watchers {
|
||||
s.unsynced.watchers.add(wa)
|
||||
s.unsynced.add(wa)
|
||||
}
|
||||
s.synced = newWatcherGroup()
|
||||
return nil
|
||||
|
|
|
@ -297,6 +297,8 @@ func TestWatchFutureRev(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()
|
||||
s := newWatchableStore(b, &lease.FakeLessor{}, nil)
|
||||
defer cleanup(s, b, tmpPath)
|
||||
|
@ -312,6 +314,8 @@ func TestWatchRestore(t *testing.T) {
|
|||
w := newStore.NewWatchStream()
|
||||
w.Watch(0, testKey, nil, rev-1)
|
||||
|
||||
time.Sleep(delay)
|
||||
|
||||
newStore.Restore(b)
|
||||
select {
|
||||
case resp := <-w.Chan():
|
||||
|
@ -327,6 +331,11 @@ func TestWatchRestore(t *testing.T) {
|
|||
case <-time.After(time.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
|
||||
|
|
Loading…
Reference in New Issue