Skip to content

Commit b247e0a

Browse files
authored
Merge pull request #20279 from ahrtr/20250704_verify_watch
[release-3.5] Add verification to verify the watch response have a bigger revision than startRev
2 parents d1d3dc2 + a4c309b commit b247e0a

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,6 +15,7 @@
1515
package mvcc
1616

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

@@ -24,6 +25,7 @@ import (
2425
"go.etcd.io/etcd/server/v3/lease"
2526
"go.etcd.io/etcd/server/v3/mvcc/backend"
2627
"go.etcd.io/etcd/server/v3/mvcc/buckets"
28+
"go.etcd.io/etcd/server/v3/verify"
2729

2830
"go.uber.org/zap"
2931
)
@@ -571,6 +573,16 @@ func (w *watcher) send(wr WatchResponse) bool {
571573
wr.Events = ne
572574
}
573575

576+
if verify.VerifyEnabled() {
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)