Repository navigation
adapter: fix flaky TestSQSFIFODelayMultiGroupPrimaryReplyLoss - #1444
Conversation
TestSQSFIFODelayMultiGroupPrimaryReplyLoss checked that the dropped primary COMMIT reached group 2 through Engine.Status().AppliedIndex. Status() is a snapshot the etcd run loop refreshes only after the whole Ready batch, while the proposal waiter is resolved right after the atomic applied index advances. The HTTP call could therefore return before the cached status caught up (CI saw 39 vs 40 under -race). Read the engine's atomic AppliedIndex via raftengine.LeaseProvider instead. It is set before resolveProposal, so the assertion stays exact and still proves the primary entry was applied on group 2. Signed-off-by: bootjp <contact@bootjp.me>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Root cause
TestSQSFIFODelayMultiGroupPrimaryReplyLossassertedf.groups[2].Engine.Status().AppliedIndex >= indexright after the HTTP call returned. In the etcd engine,Status()returns a cached snapshot thatrefreshStatus()updates only after the whole Ready batch has been processed. The apply path callssetApplied(index)and thenresolveProposal(...)(engine_normal_apply.go,publishNormalApply), so the Commit waiter, and the HTTP response, can return before the cached status reflects the entry. CI (test shard (adapter),-race) hit this on #1443: cached applied 39 vs commit index 40.The FSM had applied the entry. Only the status snapshot lagged.
Fix
Assert against the engine's atomic
AppliedIndex()(raftengine.LeaseProvider), which advances before the proposal resolves. The check is still exact, with no polling and no timeout, and it proves the same thing: the dropped primary COMMIT was applied on group 2.The later reads in the test (
Store.GetAton group 2 for the primary key and the rewritten message records) read the Pebble store directly. That store is written by the FSM beforesetApplied, so they never depended on the cached status and need no change.Behavior change / risk
Test-only. No production code changes.
Test evidence
go test -race -count=50 -run 'TestSQSFIFODelayMultiGroupPrimaryReplyLoss$' ./adapter/: ok (115s, 50/50)golangci-lint run ./adapter/: 0 issuesSelf-review
Summary by CodeRabbit