Skip to content

raft: preserve final commit notifications across peer removal - #1331

Merged
bootjp merged 2 commits into
mainfrom
design/raft-removal-commit-delivery
Oct 24, 2026
Merged

bootjp merged 2 commits into
mainfrom
design/raft-removal-commit-delivery

Conversation

@bootjp

@bootjp bootjp commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Design: docs/design/2026_10_25_implemented_raft_removal_commit_delivery.md

A committed peer removal can cancel the final queued MsgApp before the removed replica receives its commit index. The leader completes RemoveServer, but the removed replica keeps the entry uncommitted, retains its old configuration, and never shuts down. This caused the failure seen in the PR #1319 test job, and also reproduces before the dependency update.

Deliver Raft-generated, commit-covering removal notifications through independent, bounded unary RPC connections. Receiver admission is acknowledged, normal peer teardown stays immediate, and slow delivery cannot block the apply loop. Notification cleanup cannot close a replacement peer's cached connection. Delivery remains best effort during partitions; RemoveServer still reports local committed application.

The receiver-gated regression holds the final notification until local removal has completed, then verifies the removed replica updates its configuration and shuts down. It covers both stream settings and both dispatcher layouts. Additional tests cover V1/V2 changes, malformed entries, cancellation, unreachable targets, and connection replacement.

Validation

  • Regression failed before the fix; passed afterward in all four transport configurations.
  • Original failing test: 150 race-enabled repetitions across CPU parallelism 1, 2, and 4 passed.
  • Full etcd engine package tree: race tests and targeted lint passed; repeated on the final head after rebasing onto dependency-only main updates.
  • Go suite: all non-adapter packages passed. The combined adapter run exceeded its 10-minute budget with only the two full-length gRPC sequences running and no assertion failures. CI-style separate runs passed: adapter without those sequences (266s), then both full-length sequences with a fresh 15-minute budget (533s).
  • Main Jepsen harness: 310 tests / 955 assertions passed.
  • Added normal-entry Ready scan benchmark: zero allocations for batches of 1, 64, and 1024 entries, excluding outgoing messages and network/storage work.

Existing checks that do not pass: repository-wide lint reports complexity findings in kv/fsm.go and kv/shard_store_prepare_evidence_test.go; the unchanged Redis Jepsen submodule's placeholder test imports a nonexistent jepsen.redis namespace. The pre-commit hook hits the same existing lint findings, so these two commits use a per-command hook override after the targeted lint pass.

Review

  1. Data loss: persistence still precedes sends; WAL, snapshots, and quorum rules are unchanged.
  2. Concurrency / distributed failures: copied messages and addresses; independent connection ownership; bounded delivery canceled and joined on shutdown; no apply-loop blocking.
  3. Performance: no removal bookkeeping allocations for normal committed entries; additional connections only for removal notifications.
  4. Data consistency: existing Raft-generated messages and receiver handler; no synthesized entries, commit indexes, or timestamps; per-target message order preserved.
  5. Test coverage: deterministic receiver gate plus transport-mode, cancellation, deadline, decoding, and replacement coverage.

Summary by CodeRabbit

  • 機能改善
    • Raftノードの削除時、最終コミット通知を削除対象ノードへ送信するようになりました。送信はベストエフォートで、失敗しても通常の削除処理やワーカー停止を妨げません。
  • テスト
    • 通知の到達、送信失敗時のタイムアウト、シャットダウン時のキャンセル、接続の置き換えを確認するテストを追加しました。
    • 通常のメッセージ送信に関するベンチマークを追加しました。

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

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: 1cec236a-b40f-421c-8bff-248559739f26
Commits

Reviewing files that changed from the base of the PR and between 7b1eff3 and b28f303.

Files selected for processing: 5
  • docs/design/2026_10_25_implemented_raft_removal_commit_delivery.md
  • internal/raftengine/etcd/engine.go
  • internal/raftengine/etcd/removal_notification.go
  • internal/raftengine/etcd/removal_notification_benchmark_test.go
  • internal/raftengine/etcd/removal_notification_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.

Walkthrough

Ready 内のメッセージから削除対象への最終コミット通知を選別し、非同期で配信する処理を追加しました。削除後の通知到着、接続置換、キャンセル、timeout のテストと、検証記録を追加しました。

Changes: Raft削除通知

Layer / File(s) Summary
削除対象の特定とReadyの振り分け
internal/raftengine/etcd/removal_notification.go, internal/raftengine/etcd/engine.go, internal/raftengine/etcd/removal_notification_test.go, internal/raftengine/etcd/removal_notification_benchmark_test.go
コミット済みの ConfChange と ConfChangeV2 から削除対象とエントリー index を抽出します。条件に合う MsgApp を通常の送信経路から分けます。抽出テストと通常エントリーのベンチマークを追加しました。
非同期通知の配信と終了処理
internal/raftengine/etcd/removal_notification.go, internal/raftengine/etcd/removal_notification_test.go
通知ごとに新規 gRPC 接続を作成し、timeout 付きの unary Send でメッセージを送信します。接続置換、dispatcher 停止時のキャンセル、到達不能なピアへの timeout をテストします。
削除後の最終コミット通知の検証
internal/raftengine/etcd/removal_notification_test.go, docs/design/2026_10_25_implemented_raft_removal_commit_delivery.md
ストリーム送信と dispatcher lane の設定を組み合わせ、削除後に最終コミット通知が処理されることを検証します。設計、検証方針、実行結果を文書に記録しました。

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Ready as Raft Ready
  participant Sender as sendReadyMessages
  participant Goroutine as 通知goroutine
  participant Peer as 削除対象ノード
  Ready->>Sender: Ready内のメッセージ
  Sender->>Goroutine: 通知を非同期登録
  Goroutine->>Peer: 新規gRPC接続でunary Send
Loading
Merge Risk: Minimal · up to b28f3

No merge-blocking issue is established; the change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 4 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed タイトルは、ピア削除後も最終コミット通知を保持するという変更の主目的を正確かつ簡潔に示しています。
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: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 4 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: bootjp <contact@bootjp.me>
Signed-off-by: bootjp <contact@bootjp.me>
@bootjp
bootjp force-pushed the design/raft-removal-commit-delivery branch from f0f50ae to b28f303 Compare October 24, 2026 16:27
@bootjp
bootjp marked this pull request as ready for review October 24, 2026 16:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T16:39:24.358943Z b28f303 Draft marked ready
🔒 Security Review ✅ Completed 2026-10-24T16:43:18.766066Z b28f303 Draft marked ready
ℹ️ 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.

@bootjp bootjp added the agent-review-approved Current HEAD has a completed code review with zero findings label Oct 24, 2026
@bootjp
bootjp merged commit 39cee03 into main Oct 24, 2026
13 checks passed
@bootjp
bootjp deleted the design/raft-removal-commit-delivery branch October 24, 2026 16:52
@bootjp bootjp removed the agent-review-approved Current HEAD has a completed code review with zero findings label Oct 24, 2026
bootjp added a commit that referenced this pull request Oct 24, 2026
Design: docs/design/2026_10_25_proposed_review_label_permissions.md

PR #1331 completed a zero-finding review at HEAD, but the updater failed
to add its label with HTTP 403 in run 40112872960. Grant `pull-requests:
write` to the default-branch updater so it can add and remove PR labels.
Keep `issues: write` for repository label creation. Approval criteria
and trusted checkout remain unchanged.

Recovered #1331 with the existing reconciler through the authenticated
CLI, including HEAD and evidence checks before and after the write.
Confirmed `agent-review-approved` at
`b28f3030089601c0e47dae053efb2d9263b98457`. This permission change takes
effect after merge; live Actions authorization still needs verification
then.

Validation: all 83 Node tests pass; actionlint passes for all three
relevant workflows; git diff --check passes. No Go changes; the Go-only
pre-commit lint hook was skipped.

Self-review:
- Data loss: workflow permissions and documentation only.
- Concurrency: serialized reconciliation and HEAD/evidence rechecks
preserved.
- Performance: no new workflow steps or API calls.
- Consistency: approval criteria and default-branch checkout preserved;
the privileged job gains PR write scope.
- Test coverage: existing regression suite and syntax checks pass;
runtime Actions authorization remains a post-merge check.

Author: bootjp
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