Skip to content

Commit 61dae25

Browse files
authored
Merge pull request #20277 from k8s-infra-cherrypick-robot/cherry-pick-20225-to-release-3.6
[release-3.6] Add verification to verify the watch response have a bigger revision than startRev
2 parents 5897bc4 + ab13cb1 commit 61dae25

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/storage/mvcc/watchable_store.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
package mvcc
1616

1717
import (
18+
"fmt"
1819
"sync"
1920
"time"
2021

2122
"go.uber.org/zap"
2223

2324
"go.etcd.io/etcd/api/v3/mvccpb"
25+
"go.etcd.io/etcd/client/pkg/v3/verify"
2426
clientv3 "go.etcd.io/etcd/client/v3"
2527
"go.etcd.io/etcd/pkg/v3/traceutil"
2628
"go.etcd.io/etcd/server/v3/lease"
@@ -608,6 +610,16 @@ func (w *watcher) send(wr WatchResponse) bool {
608610
wr.Events = ne
609611
}
610612

613+
verify.Verify(func() {
614+
if w.startRev > 0 {
615+
for _, ev := range wr.Events {
616+
if ev.Kv.ModRevision < w.startRev {
617+
panic(fmt.Sprintf("Event.ModRevision(%d) is less than the w.startRev(%d) for watchID: %d", ev.Kv.ModRevision, w.startRev, w.id))
618+
}
619+
}
620+
}
621+
})
622+
611623
// if all events are filtered out, we should send nothing.
612624
if !progressEvent && len(wr.Events) == 0 {
613625
return true

0 commit comments

Comments
 (0)