Skip to content

Finish CI tests stuck on shutdown or a restored node identity - #25

Merged
loverustfs merged 1 commit into
mainfrom
cursor/fix-ci-suite-hangs-2c66
Nov 19, 2026
Merged

loverustfs merged 1 commit into
mainfrom
cursor/fix-ci-suite-hangs-2c66

Conversation

@loverustfs

Copy link
Copy Markdown
Contributor

Summary

The automated suite on main does not finish. This change fixes the two failures reproduced from #22 head 2007901e76dd0650e50b2a7733b9b10afca81251 on both the pull_request run https://github.com/rustfs/MetaDB/actions/runs/44519243170 and the corresponding push run (times Asia/Shanghai, 2026-11-19). This is not a first-ship pass. A green or cancelled CI run is not treated as one.

  1. backup_restore_reads_committed_keys_and_rejects_a_truncated_artifact panicked at crates/metadb-server/tests/backup_restore.rs:251 with IdentityRejected("node 1 is already bound to instance …; refusing a reused node identity"). That binary finished 3 passed, 1 failed. The backup copied cell state but omitted CLUSTER_IDENTITY. Restore then minted a new node instance id, and open rejected it against the instance already bound in the restored Raft state. The artifact now includes CLUSTER_IDENTITY, restore refuses a tree that lacks it, and open refuses to mint a new id when this node is already bound. The truncated-artifact rejection is unchanged.

  2. crates/metadb-server/tests/join_existing_group.rs did not finish and consumed the Format job budget (about 40 minutes, until the 45-minute job timeout). On the pull_request run, interrupted_join_resumes_instead_of_forking FAILED and join_sends_the_shared_secret logged "has been running for over 60 seconds" at 20:01:24, then hung until the job was cancelled at 20:41. The runner killed leftover process join_existing_group-c54f06cb87fe66e5. On the push run, both tests only logged the 60-second warning and hung until cancel, with the same leftover binary. Other tests in that file, including metadbd_processes_join_existing_group_and_fail_over, had already passed. Because cargo test --workspace waits on this binary, later tests such as scale_in_restart_tests never started.

The hang is shutdown of a leader after another voter has stopped. The background maintenance tick proposes through Raft and does not observe shutdown until that proposal returns. With the peer gone, the proposal cannot commit, so stop_tasks waits until the job is killed. Shutdown now drops an in-flight tick when the shutdown signal arrives, and the final auxiliary drain is bounded at 10 seconds. If that drain does not finish, shutdown still flushes local memtables and stops Raft. The assertions in the join tests are unchanged.

Testing

  • cargo test -p metadb-server --test backup_restore --test join_existing_group --test e2e_cluster_evolution_tests
  • cargo test -p metadb-server --tests
  • cargo test -p metadb-cluster -p metadb-raft
  • cargo clippy -p metadb-server -p metadb-raft -p metadb-cluster --all-targets -- -D warnings
Open in Web Open in Cursor 

Backup artifacts now include CLUSTER_IDENTITY so a restore reopens the same node instance instead of minting one the replicated binding rejects. Shutdown cancels an in-flight maintenance tick and bounds the auxiliary drain, so a departed voter cannot pin the process on a proposal that can no longer commit.

Co-authored-by: RustFS <hello@rustfs.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Cancelling split startup can leave a child registered in the router but untracked by the host, causing final flushing and explicit Raft shutdown to miss it.

1 open issue
What changed in this PR

Addresses two failures that prevented the workspace test suite from finishing: restored node identity rejection and shutdown hanging after a Raft voter stops.

Changes:

  • Preserve CLUSTER_IDENTITY in backups and require it during restore.
  • Reject missing identity metadata when the node already has a persisted instance binding.
  • Cancel in-flight background maintenance during shutdown and bound the final drain with a local-flush fallback.
File Description
crates/​metadb-server/​src/​lib.rs Adds shutdown-aware maintenance cancellation and a 10-second drain timeout.
crates/​metadb-raft/​src/​backup.rs Copies node identity metadata and validates its presence during restore.
crates/​metadb-cluster/​src/​cell_manager.rs Recovers bindings before identity creation and rejects unsafe identity regeneration.

Review effort: Balanced

Comment on lines +722 to +723
_ = bg_rx.changed() => break,
_ = c.run_maintenance_tick_inner(false) => {}
@loverustfs
loverustfs merged commit a5f848e into main Nov 19, 2026
8 checks passed
loverustfs added a commit that referenced this pull request Nov 19, 2026
Keep a publish-window lock from the final shard-directory and registry check through the artifact rename, read offline MANIFEST files without appending or truncating a torn tail, and hold the crash-scratch lock through the byte copy.

Conflict resolution on backup.rs keeps #25's CLUSTER_IDENTITY rules: backup refuses a cell directory that lacks the file, and restore refuses a tree whose manifest lists CELL_MANAGER_STATE without the matching CLUSTER_IDENTITY.

A merge is not a first-ship pass.
loverustfs added a commit that referenced this pull request Nov 19, 2026
Rebuild a missing published snapshot from the LSM, or fail closed with snapshot unrecoverable so a purged shard is not advertised as a live voter and does not accept writes onto an empty LSM. Start checks the unrecoverable latch before register_group. routes_for_live_status probes the snapshot directory through ensure_published_snapshot_sync. There is no fourth copy of the command log.

This branch is one commit behind main after #19. A local merge into 3ed51ee has no text conflicts and keeps both #19's SHARD_SET publish lock and #25's identity and shutdown bounds.

A merge is not a first-ship pass.
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.

3 participants