Skip to content

Commit e844573

Browse files
ahrtrk8s-infra-cherrypick-robot
authored andcommitted
Add verification to verify the watch response have a bigger revision than minRev
Signed-off-by: Benjamin Wang <[email protected]>
1 parent d1d3dc2 commit e844573

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/mvcc/watchable_store.go

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

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

2122
"go.etcd.io/etcd/api/v3/mvccpb"
23+
"go.etcd.io/etcd/client/pkg/v3/verify"
2224
clientv3 "go.etcd.io/etcd/client/v3"
2325
"go.etcd.io/etcd/pkg/v3/traceutil"
2426
"go.etcd.io/etcd/server/v3/lease"
@@ -571,6 +573,16 @@ func (w *watcher) send(wr WatchResponse) bool {
571573
wr.Events = ne
572574
}
573575

576+
verify.Verify(func() {
577+
if w.startRev > 0 {
578+
for _, ev := range wr.Events {
579+
if ev.Kv.ModRevision < w.startRev {
580+
panic(fmt.Sprintf("Event.ModRevision(%d) is less than the w.startRev(%d) for watchID: %d", ev.Kv.ModRevision, w.startRev, w.id))
581+
}
582+
}
583+
}
584+
})
585+
574586
// if all events are filtered out, we should send nothing.
575587
if !progressEvent && len(wr.Events) == 0 {
576588
return true

0 commit comments

Comments
 (0)