Skip to content

adapter: fix flaky TestSQSFIFODelayMultiGroupPrimaryReplyLoss - #1444

Merged
bootjp merged 1 commit into
mainfrom
adapter/fix-sqs-fifo-multigroup-flake
Nov 12, 2026
Merged

bootjp merged 1 commit into
mainfrom
adapter/fix-sqs-fifo-multigroup-flake

Conversation

@bootjp

@bootjp bootjp commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Root cause

TestSQSFIFODelayMultiGroupPrimaryReplyLoss asserted f.groups[2].Engine.Status().AppliedIndex >= index right after the HTTP call returned. In the etcd engine, Status() returns a cached snapshot that refreshStatus() updates only after the whole Ready batch has been processed. The apply path calls setApplied(index) and then resolveProposal(...) (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.GetAt on group 2 for the primary key and the rewritten message records) read the Pebble store directly. That store is written by the FSM before setApplied, 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 issues

Self-review

  1. Data loss: test-only, n/a.
  2. Concurrency: removes a read of a lagging cache. The atomic is published before the proposal resolves, so this is ordered.
  3. Performance: n/a.
  4. Consistency: the assertion is unchanged in strength: applied index >= the commit index of the primary.
  5. Coverage: same assertions, now deterministic.

Summary by CodeRabbit

  • テスト
    • FIFO遅延メッセージの複数グループ処理に関するテストで、適用状態の確認方法を更新しました。

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T15:41:18.101669Z 862bb2d PR opened
🔒 Security Review ✅ Completed 2026-11-12T15:42:08.217129Z 862bb2d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

テストの適用済みインデックス確認を、Raft ステータスのスナップショットから LeaseProvider.AppliedIndex() に変更しました。取得値が期待するインデックス以上であることを検証します。

Changes: SQS FIFO テスト

Layer / File(s) Summary
適用済みインデックスの検証
adapter/sqs_fifo_delay_multigroup_test.go
LeaseProvider を実装していない場合はテストを失敗させます。実装している場合は、AppliedIndex() の値が期待するインデックス以上であることを確認します。

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Possibly related PRs

  • bootjp/elastickv#1380: 同じテスト関数の応答喪失シナリオで、HTTP 応答の期待値を変更します。
Merge Risk: Minimal · up to 862bb

This is a test-only change that makes a flaky assertion deterministic. It has no production impact and is ready to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed タイトルは変更内容と一致している。テスト TestSQSFIFODelayMultiGroupPrimaryReplyLoss が不安定だった問題を修正する変更であり、変更ファイル adapter/sqs_fifo_delay_multigroup_test.go の範囲と合っている。タイトルは短く、主要な変更を示している。修正対象が「不安定性」であり、AppliedIndex の参照先変更という…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

タイトルは変更内容と一致している。テスト TestSQSFIFODelayMultiGroupPrimaryReplyLoss が不安定だった問題を修正する変更であり、変更ファイル adapter/sqs_fifo_delay_multigroup_test.go の範囲と合っている。タイトルは短く、主要な変更を示している。修正対象が「不安定性」であり、AppliedIndex の参照先変更という具体的な手段までは示していないが、それは必須ではない。

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 23d210c0-7252-43e0-b5b1-3655ce2c9973
Commits

Reviewing files that changed from the base of the PR and between d6e8fbb and 862bb2d.

Files selected for processing: 1

  • adapter/sqs_fifo_delay_multigroup_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@bootjp
bootjp merged commit 988180d into main Nov 12, 2026
18 checks passed
@bootjp
bootjp deleted the adapter/fix-sqs-fifo-multigroup-flake branch November 12, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant