Skip to content

Commit f946ff2

Browse files
committed
robustness: reproduce #20221
Targeting bug fix #20281 Signed-off-by: Chun-Hung Tseng <henrytseng@google.com>
1 parent 4f6863f commit f946ff2

File tree

4 files changed

+83
-5
lines changed

4 files changed

+83
-5
lines changed

tests/robustness/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ test-robustness-issue20221: /tmp/etcd-bc47e771-failpoints/bin
8080
GO_TEST_FLAGS='-v -run=TestRobustnessRegression/Issue20221 -count 100 -failfast --bin-dir=/tmp/etcd-bc47e771-failpoints/bin' $(TOPLEVEL_MAKE) test-robustness && \
8181
echo "Failed to reproduce" || echo "Successful reproduction"
8282

83+
.PHONY: test-robustness-issue20221-event
84+
test-robustness-issue20221-event: /tmp/etcd-44a094a2-failpoints/bin
85+
GO_TEST_FLAGS='-v -run=TestRobustnessRegression/Issue20221-event -count 100 -failfast --bin-dir=/tmp/etcd-44a094a2-failpoints/bin' $(TOPLEVEL_MAKE) test-robustness && \
86+
echo "Failed to reproduce" || echo "Successful reproduction"
87+
8388
# Etcd API usage by Kubernetes
8489

8590
.PHONY: k8s-coverage
@@ -144,6 +149,19 @@ $(GOPATH)/bin/gofail: $(REPOSITORY_ROOT)/tools/mod/go.mod $(REPOSITORY_ROOT)/too
144149
$(MAKE) gofail-enable; \
145150
$(MAKE) build;
146151

152+
/tmp/etcd-44a094a2-failpoints/bin: $(GOPATH)/bin/gofail
153+
rm -rf /tmp/etcd-44a094a2-failpoints/
154+
mkdir -p /tmp/etcd-44a094a2-failpoints/
155+
cd /tmp/etcd-44a094a2-failpoints/; \
156+
git init; \
157+
git remote add origin https://github.com/etcd-io/etcd.git; \
158+
git fetch --depth 1 origin 44a094a20a7a0ac16cf88c9f21b6ca90e9f85cf5; \
159+
git checkout FETCH_HEAD; \
160+
cp -r $(REPOSITORY_ROOT)/tests/robustness/patches/removeVerifyModRevision . && \
161+
patch --fuzz=0 server/storage/mvcc/watchable_store.go ./removeVerifyModRevision/watchable_store.patch && \
162+
$(MAKE) gofail-enable; \
163+
$(MAKE) build;
164+
147165
/tmp/etcd-release-3.6-failpoints/bin: $(GOPATH)/bin/gofail
148166
rm -rf /tmp/etcd-release-3.6-failpoints/
149167
mkdir -p /tmp/etcd-release-3.6-failpoints/
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
diff --git a/server/storage/mvcc/watchable_store.go b/server/storage/mvcc/watchable_store.go
2+
index 1996ee6..ed9fe1c 100644
3+
--- a/server/storage/mvcc/watchable_store.go
4+
+++ b/server/storage/mvcc/watchable_store.go
5+
@@ -15,14 +15,12 @@
6+
package mvcc
7+
8+
import (
9+
- "fmt"
10+
"sync"
11+
"time"
12+
13+
"go.uber.org/zap"
14+
15+
"go.etcd.io/etcd/api/v3/mvccpb"
16+
- "go.etcd.io/etcd/client/pkg/v3/verify"
17+
clientv3 "go.etcd.io/etcd/client/v3"
18+
"go.etcd.io/etcd/pkg/v3/traceutil"
19+
"go.etcd.io/etcd/server/v3/lease"
20+
@@ -610,15 +608,6 @@ func (w *watcher) send(wr WatchResponse) bool {
21+
wr.Events = ne
22+
}
23+
24+
- verify.Verify(func() {
25+
- if w.startRev > 0 {
26+
- for _, ev := range wr.Events {
27+
- if ev.Kv.ModRevision < w.startRev {
28+
- panic(fmt.Sprintf("Event.ModRevision(%d) is less than the w.startRev(%d) for watchID: %d", ev.Kv.ModRevision, w.startRev, w.id))
29+
- }
30+
- }
31+
- }
32+
- })
33+
34+
// if all events are filtered out, we should send nothing.
35+
if !progressEvent && len(wr.Events) == 0 {

tests/robustness/scenarios/scenarios.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,25 @@ func Regression(t *testing.T) []TestScenario {
327327
e2e.WithSnapshotCatchUpEntries(10),
328328
),
329329
})
330+
scenarios = append(scenarios, TestScenario{
331+
Name: "Issue20221-event",
332+
Failpoint: failpoint.BlackholeUntilSnapshot,
333+
Watch: client.WatchConfig{
334+
RequestProgress: true,
335+
},
336+
Profile: traffic.Profile{
337+
KeyValue: &traffic.KeyValueHigh,
338+
Watch: &traffic.WatchWithClusterClientSwitching,
339+
},
340+
Traffic: traffic.EtcdPut,
341+
Cluster: *e2e.NewConfig(
342+
e2e.WithSnapshotCount(10),
343+
e2e.WithPeerProxy(true),
344+
e2e.WithIsPeerTLS(true),
345+
e2e.WithWatchProcessNotifyInterval(10*time.Millisecond),
346+
e2e.WithSnapshotCatchUpEntries(10),
347+
),
348+
})
330349
if v.Compare(version.V3_5) >= 0 {
331350
opts := []e2e.EPClusterOption{
332351
e2e.WithSnapshotCount(100),

tests/robustness/traffic/traffic.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ func (r Range) Rand() int64 {
4949
}
5050

5151
var (
52-
DefaultLeaseTTL int64 = 7200
53-
RequestTimeout = 200 * time.Millisecond
54-
WatchTimeout = 500 * time.Millisecond
55-
MultiOpTxnOpCount = 4
56-
MinimalCompactionPeriod = 100 * time.Millisecond
52+
DefaultLeaseTTL int64 = 7200
53+
DefaultClusterClientSwitchingInterval = 500 * time.Millisecond
54+
RequestTimeout = 200 * time.Millisecond
55+
WatchTimeout = 500 * time.Millisecond
56+
MultiOpTxnOpCount = 4
57+
MinimalCompactionPeriod = 100 * time.Millisecond
5758

5859
KeyValueVeryLow = KeyValue{
5960
MinimalQPS: 50,
@@ -93,6 +94,11 @@ var (
9394
ClusterClientCount: 2,
9495
RivisionOffsetRange: &Range{Min: 10, Max: 100},
9596
}
97+
WatchWithClusterClientSwitching = Watch{
98+
MemberClientCount: 6,
99+
ClusterClientCount: 2,
100+
EndpointSwitchPeriod: &DefaultClusterClientSwitchingInterval,
101+
}
96102
CompactionDefault = Compaction{
97103
Period: 200 * time.Millisecond,
98104
}

0 commit comments

Comments
 (0)