Skip to content

refactor: group Raft bootstrap and join flags (M2 part 7, completes M2) - #1443

Merged
bootjp merged 2 commits into
mainfrom
design/root-package-decomposition-m2g
Nov 12, 2026
Merged

bootjp merged 2 commits into
mainfrom
design/root-package-decomposition-m2g

Conversation

@bootjp

@bootjp bootjp commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Design: docs/design/2026_11_12_partial_root_package_decomposition.md

M2 part 7, stacked on #1442. Retarget it to main once #1442 merges. This is the last M2 part: after it, the root package registers no flag as a package global.

Changes

  • raftBootstrapFlags (main_raft_peers.go) holds:
    • --raftBootstrap
    • --raftBootstrapMembers
    • --raftGroupPeers
    • --raftJoinMembers
    • --raftJoinAsLearner
    • --raftBootstrapPeerConfigDir, which moved here from main_bootstrap_launch.go
  • raftBootstrapConfig gains peerConfigDir and joinAsLearner, set in resolveRuntimeInputs. They reach:
    • loadProtectedBootstrapDomain / validateProtectedBootstrapDomain / loadGroupBootstrapSpec: these take the dir explicitly.
    • The shard-group builder's protected-spec and protected-TSO checks.
    • buildRuntimeForGroup.
    • buildDedicatedTSOGroup / buildProtectedDedicatedTSOGroup: these gain a joinAsLearner parameter after bootstrap.
  • serversInput.raftJoining replaces the --raftJoinMembers read in the server runner. It is computed by raftBootstrapFlags.joining(), with the same trim semantics.
  • Tests:
    • The protected-bootstrap e2e fixtures (single-group, multi-node, TSO, rotation, offline encryption, recovery race, external rotation) pass the peer-config dir through raftBootstrapConfig and their start helpers. They no longer overwrite a process global.
    • The require.Empty(*raftBootstrapPeerConfigDir) leak guards are gone; there is no global left to leak.
    • The two launch tests now run t.Parallel.
  • main_flags.go has no package flag globals left. The design doc marks M2 implemented, and CLAUDE.md states the rule as settled.

Behavior change

None:

  • Flag names, defaults and help text are unchanged: -help output is identical to the base.
  • bootstrap is still --raftBootstrap || anyBootstrapServers().
  • The protected path still turns on exactly when the peer-config dir is non-empty.

Risk

Low to moderate. The values are read-only after parsing. The one thing to check is that every production path into group construction carries bootstrapCfg. It does: run() → buildShardGroupsWithEncryptionWiring → buildShardGroups → loadProtectedBootstrapDomain and shardGroupBuilder{bootstrapCfg}. That is the only production path.

Test evidence

  • go test -race -count=1 .: ok (229s).
  • golangci-lint: 0 issues.
  • scripts/check-production-imports.sh: ok.
  • -help output: identical to the base binary.
  • Test list: identical apart from the new TestRuntimeInputsCarryBootstrapFlagsIntoBootstrapConfig and TestRaftBootstrapFlagsJoining.
  • Jepsen: not run. Nothing in replication, MVCC or OCC changed. The protected-bootstrap e2e suites above cover the touched start-up path.

Self-review

  1. Data loss: no write or apply path changes. Protected groups still refuse to open without the domain when a peer-config dir is set.
  2. Concurrency: the values are immutable after parsing. Removing the global means bootstrap tests no longer race on shared state, and the launch tests can run in parallel.
  3. Performance: start-up only.
  4. Consistency: the commit-ts fence start-up check, protected-domain loading, the spec-presence checks and learner join all read the same parsed values as before.
  5. Test coverage: new tests cover the flags → raftBootstrapConfig mapping and joining(). All protected-bootstrap e2e fixtures now build their config explicitly.

Move --raftBootstrap, --raftBootstrapMembers, --raftGroupPeers,
--raftJoinMembers, --raftJoinAsLearner and --raftBootstrapPeerConfigDir
into raftBootstrapFlags. The peer-config dir and the learner expectation
travel in raftBootstrapConfig to protected-domain loading and the
shard-group builder, including both dedicated TSO group builders.

The protected-bootstrap e2e fixtures pass the peer-config dir instead of
overwriting a process global; the launch tests now run in parallel. The
root package no longer registers any flag as a package global.

No flag name, default or help text changes.

Signed-off-by: bootjp <contact@bootjp.me>
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:29:57.897809Z d7f7d8c PR opened
🔒 Security Review ✅ Completed 2026-11-12T15:31:53.050669Z d7f7d8c 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

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

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: 05ed3c6d-37bb-4a6e-b95d-4b015d5abdcc
Commits

Reviewing files that changed from the base of the PR and between 4c2c46a and d7f7d8c.

Files selected for processing: 25

  • CLAUDE.md
  • docs/design/2026_11_12_partial_root_package_decomposition.md
  • main.go
  • main_bootstrap_artifact_commands_test.go
  • main_bootstrap_enablement_e2e_test.go
  • main_bootstrap_enablement_multi_e2e_test.go
  • main_bootstrap_external_rotation_e2e_test.go
  • main_bootstrap_flag_test.go
  • main_bootstrap_launch.go
  • main_bootstrap_launch_test.go
  • main_bootstrap_network_redis_e2e_test.go
  • main_bootstrap_offline_encryption_e2e_test.go
  • main_bootstrap_recovery_race_test.go
  • main_bootstrap_rotation_e2e_test.go
  • main_bootstrap_tso.go
  • main_bootstrap_tso_baseline_test.go
  • main_bootstrap_tso_enablement_e2e_test.go
  • main_bootstrap_tso_recovery_test.go
  • main_bootstrap_tso_test.go
  • main_flags.go
  • main_raft_peers.go
  • main_raft_topology_flags_test.go
  • main_runtime_config.go
  • main_server_runner.go
  • main_shard_groups.go
  • 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

Base automatically changed from design/root-package-decomposition-m2f to main November 12, 2026 15:44
@bootjp
bootjp merged commit 746dfa3 into main Nov 12, 2026
17 of 19 checks passed
@bootjp
bootjp deleted the design/root-package-decomposition-m2g branch November 12, 2026 15:50
bootjp added a commit that referenced this pull request Nov 12, 2026
## 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.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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