Skip to content

kv: run tests in parallel - #1391

Merged
bootjp merged 1 commit into
mainfrom
test/parallel-kv
Nov 6, 2026
Merged

bootjp merged 1 commit into
mainfrom
test/parallel-kv

Conversation

@bootjp

@bootjp bootjp commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Summary

Adds t.Parallel() to 414 top-level tests in ./kv and ./kv/kvtest that did not call it (399 in kv, 15 in kvtest_test; 1040 in kv already did). Part of the effort to parallelize the Go test suite; CI-side sharding is in #1387.

Candidates were picked with a go/ast scan that skips any test which (directly or through same-package helpers) calls t.Setenv/os.Setenv/os.Chdir, writes a package-level variable from test code, calls process-global setters (slog.SetDefault, prometheus.MustRegister, signal.Notify, runtime.GOMAXPROCS(n), …), or carries a comment about parallelism.

Left serial (5 tests):

  • writes a package-level hook/knob from test code (3): TestEncodeObservedRouteVersionZeroGatedForRollingUpgrade (observedRouteVersionZeroWireEncodingEnabled), TestLeaseState_InvalidateClearsExpiryBeforeBumpingGen (onInvalidateBetweenStores, already documented as not parallel), TestTransactionManagerBatchesConcurrentRawCommits (rawBatchWindow)
  • t.Setenv (1): TestTSOControlDiskReopen
  • re-execs itself as a crash child via os.Exit (1): TestFSMApplyBatch_CrashBetweenRequestsLeavesNoPartialEntry

None reverted by hand. Reviewed by hand:

  • raftPayloadPublicationID (reached by 6 tests through SetObservedRaftPayloadWrapInMutation) is a process-wide monotonic ID allocator; tests only compare observations for equality and never assert on the identity value, so they stay parallel.
  • No fixed-port listeners (all use 127.0.0.1:0 or bufconn); literal host:port strings are data only. No default Prometheus registry, goroutine-count or alloc assertions. No package-level Configure*/Set* helpers in kv.
  • Serial tests that write package globals restore them via t.Cleanup/defer and finish before any top-level parallel test is released.

Behavior change / risk

Test-only. No production code touched. Residual risk: a few tests assert wall-clock bounds (raft_engine_test.go verifyLeader upper bound of 2x timeout, leader_proxy_test.go retry-budget upper bound); they passed under -count=3 with the higher concurrency but could become load-sensitive on a slow CI runner.

Test evidence

  • go test -race -count=3 -timeout=60m ./kv ./kv/kvtest — ok
  • package time (-race -count=1): kv 127.9s → 70.6s, kv/kvtest 1.9s → 2.0s
  • golangci-lint run ./kv/... — 0 issues; gofmt -l kv — clean
  • No flakes observed

Self-review

  1. Data loss: test-only change; no storage, Raft or FSM code touched.
  2. Concurrency: parallel tests each build their own stores/engines/HLC instances; package-global writers stay serial; the only shared mutable global reached is an atomic monotonic ID allocator. -race -count=3 clean.
  3. Performance: kv package wall time under -race roughly halved.
  4. Data consistency: no change to MVCC/OCC/HLC semantics; test assertions untouched.
  5. Test coverage: no tests added or removed; only execution scheduling changes.

Signed-off-by: bootjp <contact@bootjp.me>
@coderabbitai

coderabbitai Bot commented Nov 6, 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 17 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: 0db1014f-99a0-44eb-a27f-732a701e9251
Commits

Reviewing files that changed from the base of the PR and between 57b4754 and 1c8089e.

Files selected for processing: 85

  • kv/active_timestamp_tracker_test.go
  • kv/backup_codec_test.go
  • kv/compactor_test.go
  • kv/coordinator_prepare_evidence_test.go
  • kv/encryption_apply_admission_test.go
  • kv/fakes_test.go
  • kv/fsm_apply_entry_identity_test.go
  • kv/fsm_apply_observer_test.go
  • kv/fsm_backup_test.go
  • kv/fsm_batch_entry_test.go
  • kv/fsm_dynamodb_timestamp_collision_test.go
  • kv/fsm_hlc_observe_test.go
  • kv/fsm_migration_cleanup_test.go
  • kv/fsm_migration_configuration_test.go
  • kv/fsm_migration_deterministic_test.go
  • kv/fsm_migration_evidence_fixture_test.go
  • kv/fsm_migration_namespace_test.go
  • kv/fsm_migration_partition_negative_test.go
  • kv/fsm_migration_partition_test.go
  • kv/fsm_migration_size_guard_test.go
  • kv/fsm_migration_source_ownership_test.go
  • kv/fsm_migration_transfer_semantics_test.go
  • kv/fsm_occ_test.go
  • kv/fsm_onephase_dedup_test.go
  • kv/fsm_raft_bootstrap_activation_test.go
  • kv/fsm_raft_bootstrap_test.go
  • kv/fsm_restore_origin_encrypted_test.go
  • kv/fsm_restore_origin_real_test.go
  • kv/fsm_restore_origin_test.go
  • kv/grpc_conn_cache_runtime_test.go
  • kv/kvtest/coordinator_test.go
  • kv/leader_routed_store_test.go
  • kv/lease_warmup_test.go
  • kv/migration_broadcast_admission_test.go
  • kv/migration_frontier_admission_performance_test.go
  • kv/migration_frontier_admission_test.go
  • kv/migration_frontier_selection_test.go
  • kv/migration_namespace_compat_test.go
  • kv/migration_namespace_protocol_test.go
  • kv/migration_namespace_upgrade_test.go
  • kv/migration_partition_codec_property_test.go
  • kv/migration_partition_history_test.go
  • kv/migration_partition_protocol_readiness_test.go
  • kv/migration_prefix_ownership_test.go
  • kv/migration_promote_control_state_test.go
  • kv/migration_public_admission_test.go
  • kv/migration_resplit_acceptance_test.go
  • kv/migration_serving_test.go
  • kv/owned_proposal_test.go
  • kv/phase_d_control_admission_test.go
  • kv/prepare_abort_recovery_test.go
  • kv/prepare_evidence_namespace_test.go
  • kv/raft_bootstrap_recovery_test.go
  • kv/raft_payload_observation_test.go
  • kv/shard_router_test.go
  • kv/shard_store_partition_txn_test.go
  • kv/shard_store_prepare_evidence_test.go
  • kv/shard_store_test.go
  • kv/sharded_coordinator_abort_test.go
  • kv/sharded_coordinator_crash_boundary_test.go
  • kv/sharded_coordinator_crash_test.go
  • kv/sharded_coordinator_del_prefix_test.go
  • kv/sharded_coordinator_strict_result_test.go
  • kv/sharded_coordinator_txn_test.go
  • kv/sharded_integration_test.go
  • kv/snapshot_encryption_checkpoint_test.go
  • kv/snapshot_prepare_checkpoint_test.go
  • kv/snapshot_sst_ingest_test.go
  • kv/snapshot_test.go
  • kv/startup_control_rpc_test.go
  • kv/timestamp_admission_test.go
  • kv/transaction_batch_test.go
  • kv/tso_applied_leader_test.go
  • kv/tso_bootstrap_baseline_test.go
  • kv/tso_bootstrap_control_test.go
  • kv/tso_bootstrap_guard_test.go
  • kv/tso_fsm_test.go
  • kv/tso_pending_joint_recovery_test.go
  • kv/tso_pending_seal_test.go
  • kv/tso_pending_test.go
  • kv/tso_pending_upgrade_test.go
  • kv/tso_raft_test.go
  • kv/tso_restore_context_test.go
  • kv/tso_runtime_test.go
  • kv/tso_test.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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 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-11-06T12:55:29.587746Z 1c8089e PR opened
🔒 Security Review ✅ Completed 2026-11-06T12:58:04.135699Z 1c8089e 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.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

TLA+ spec divergence review (auto-triggered)

This PR touches files that the TLA+ safety spec has an anchor on (per
docs/design/2026_05_28_implemented_tla_safety_spec.md §3),
so an AI review is requested below to verify the implementation has not drifted
from the model.

Anchored files changed in this PR head (1c8089e):

  • kv/tso_applied_leader_test.go
  • kv/tso_bootstrap_baseline_test.go
  • kv/tso_bootstrap_control_test.go
  • kv/tso_bootstrap_guard_test.go
  • kv/tso_fsm_test.go
  • kv/tso_pending_joint_recovery_test.go
  • kv/tso_pending_seal_test.go
  • kv/tso_pending_test.go
  • kv/tso_pending_upgrade_test.go
  • kv/tso_raft_test.go
  • kv/tso_restore_context_test.go
  • kv/tso_runtime_test.go
  • kv/tso_test.go

What to check, by subsystem:

  • kv/hlc*.go — Next() must respect the HLC-4 preconditions (i)/(ii)/(iii) from the design doc: bounded skew, logical-counter handoff on leader change (the TSO allocation floor; legacy modes have none and are pinned as known gaps), and the NextFenced ceiling fence (fail-closed when wall_now >= physicalCeiling or when the next value's physical half exceeds it). Any change to the bit layout (48/16), the CAS loop, or the ceiling getter/setter is in scope.
  • kv/tso*.go — RaftTSOAllocator must Observe the committed allocation floor before reserving and commit the new floor before handing a window out (HLC.tla IssuanceMode = "tso").
  • kv/coordinator.go, kv/sharded_coordinator.go — RunHLCLeaseRenewal, hlcRenewalInterval, hlcPhysicalWindowMs constants, and which node stamps StartTS / CommitTS (HLC-3; legacy ShardedCoordinator stamping is the known gap G10). Any change to renewal cadence, group selection, or fail-closed behaviour is in scope.
  • kv/transaction.go, kv/lock_resolver.go — OCC commit-ts assignment, lock-map encoding (key, lock_ts) -> start_ts, and the LockResolver action OCC-3 depends on (OCC.tla; G0 / G1 are pinned as known gaps).
  • kv/fsm.go, kv/fsm_migration_serving.go — FSM apply of HLC lease entries (SetPhysicalCeiling), the one-phase / PREPARE / COMMIT validation OCC.tla models, verifyComposed1, and the migration serving guard Composed.tla relies on for unpinned writes.
  • store/mvcc_store.go, store/lsm_store.go — version visibility, resumable compaction, the commit-ts apply fence, and the MVCC-1 / MVCC-4 / MVCC-5 invariants.
  • adapter/ts.go — the snapshot start timestamp OCC.tla assumes (applied watermark; MaxUint64 on an empty store).
  • distribution/** — route catalog versioning, SplitRange atomicity, and CatalogWatcher async fan-out (M4 scope).

If the change is correct but requires a spec update, edit tla/hlc/HLC.tla (or the corresponding M2..M5 module once landed) and the design doc in the same PR. The tla-check workflow runs the TLC model check on the same paths.


@claude review please verify TLA+ spec divergence per the checklist above.

@codex review please verify TLA+ spec divergence per the checklist above.

@bootjp
bootjp merged commit e0f6af5 into main Nov 6, 2026
15 checks passed
@bootjp
bootjp deleted the test/parallel-kv branch November 6, 2026 13:14
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