Commit ba3f5bf
committed
test(redis): wait for follower apply catch-up in MultiExec list tests
TestRedis_MultiExec_DelThenRPushRecreatesList was intermittently failing
under -race on CI (PR #577): after MULTI / DEL list / RPUSH list new1
new2 / EXEC, the final direct store.ScanAt(..., readTS) on nodes[1]
returned the pre-EXEC ["old1","old2"] even though the immediately
preceding LRANGE via the redis client correctly returned
["new1","new2"].
Why the race exists:
- The go-redis client connects to nodes[1], which is not necessarily the
raft leader.
- LRANGE goes through the adapter's LeaseRead / LinearizableRead path,
which blocks until the local apply watermark reaches a safe point, so
it observes the EXEC commit even on a slightly-lagging follower.
- readTS() (adapter/ts.go:snapshotTS) returns the local store's
LastCommitTS() directly, with no wait-apply. On a follower (or a
leader that has just responded to the client), LastCommitTS can
momentarily trail the raft-committed EXEC because the test reads it
on a different code path than the one that drove the client-visible
wait.
- The direct ScanAt(readTS) therefore sees the stale, pre-EXEC state.
Fix: introduce waitForListState(t, node, key, expectedLen,
expectedValues) that polls resolveListMeta AND the raw item scan at the
node-local readTS via require.Eventually (250ms interval, 5s timeout)
until both reflect the expected post-EXEC state. This is a real
synchronization on the raft apply progress of the target node, not a
timing hack: it succeeds on the first iteration when the node is
already caught up and only retries while the apply is genuinely behind.
Use it in place of the ad-hoc readTS/resolveListMeta/ScanAt block in
TestRedis_MultiExec_DelThenRPushRecreatesList.1 parent 4426f58 commit ba3f5bf
1 file changed
Lines changed: 55 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
15 | 65 | | |
16 | 66 | | |
17 | 67 | | |
| |||
194 | 244 | | |
195 | 245 | | |
196 | 246 | | |
197 | | - | |
198 | | - | |
199 | 247 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
222 | 253 | | |
223 | 254 | | |
224 | 255 | | |
| |||
0 commit comments