Skip to content

Move resharding version gate to pre-flight check - #8123

Closed
KShivendu wants to merge 9 commits into
devfrom
fix/resharding-version-gate-preflight
Closed

KShivendu wants to merge 9 commits into
devfrom
fix/resharding-version-gate-preflight

Conversation

@KShivendu

@KShivendu KShivendu commented Feb 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds a pre-flight version check before proposing resharding transfers to consensus, returning a clean API error instead of
crashing consensus.

Problem

The version gate in Collection::start_shard_transfer() checks all_peers_at_version() during consensus apply. When this check fails, it returns a ServiceError which stops consensus entirely. It's affecting all CM resharding integration tests.

This can happen in two scenarios:

  1. Resharding during cluster scaling: When a node recently joined or restarted, its address is registered immediately but
    metadata propagates asynchronously. If a resharding transfer is applied through consensus in that window, the check fails
    because id_to_address.len() > id_to_metadata.len().

  2. Resharding during rolling upgrade: If some peers are still running a version older than 1.16.4-dev, the version
    check fails. Instead of a clean rejection, consensus stops.

Fix

Added the same version check as a pre-flight in TocDispatcher::start_shard_transfer() before proposing to consensus. This
way failures return a normal API error that callers can handle/retry, instead of killing consensus.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@lib/collection/src/collection/shard_transfer.rs`:
- Around line 102-117: The error arises from passing format! results into
another format! (Clippy uninlined_format_args); fix by building the peers
strings first and then using those variables in a single format! call. In
shard_transfer.rs, inside the block that returns
CollectionError::service_error(...) compute two local strings (e.g.,
versions_str = self.channel_service.peers_versions().into_iter().map(|(p,v)|
format!("{}: {}", p, v)).collect::<Vec<_>>().join(", ") and addresses_str =
self.channel_service.peers_addresses().into_iter().map(|(p,a)| format!("{}: {}",
p, a)).collect::<Vec<_>>().join(", ")), then call format!("Cannot start
resharding transfer: not all peers support the required version {} while they
are at versions {:?} -> {:?}", *NEW_UPDATE_ON_RESHARDING_VERSION, versions_str,
addresses_str) and return that in CollectionError::service_error to eliminate
nested format! calls.

In `@lib/storage/src/content_manager/toc/transfer.rs`:
- Around line 71-94: The pre-flight version check for resharding silently skips
when self.toc.upgrade() returns None; change the behavior to return an error
instead of proceeding. In the branch where transfer_config.is_resharding() and
self.toc.upgrade() yields None, return an appropriate error (e.g., ServiceError
or CollectionError::pre_condition_failed) consistent with
recovered_switch_to_partial rather than silently continuing; keep the existing
version check using NEW_UPDATE_ON_RESHARDING_VERSION and the detailed peers info
when toc is present, but if toc is dropped produce a clear error indicating the
TOC was dropped so the caller can handle the failure.
🧹 Nitpick comments (2)
lib/storage/src/content_manager/toc/transfer.rs (1)

75-91: Consider using {} instead of {:?} for the formatted peer info strings.

The {:?} debug format on the already-formatted and joined String values will wrap them in extra quotes in the error message (e.g., "0: 1.16.3, 1: 1.16.4"). Using {} would produce cleaner output.

-                        "Cannot start resharding transfer: not all peers support the required \
-                         version {} while they are at versions {:?} -> {:?}",
+                        "Cannot start resharding transfer: not all peers support the required \
+                         version {} while they are at versions [{}] -> [{}]",
lib/collection/src/collection/shard_transfer.rs (1)

97-100: Clarify the comment: service_error does not panic.

The comment says "let it panic via service_error so we notice the pre-flight was bypassed." However, CollectionError::service_error returns an Err, it doesn't panic. The concern from the PR description is that this error during consensus apply stops consensus, which is the actual severity — but it's not a panic. Consider rewording to avoid confusion.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@lib/collection/src/collection/shard_transfer.rs`:
- Around line 97-100: The comment incorrectly states that
CollectionError::service_error(...) will panic; update the comment near the
TocDispatcher::start_shard_transfer pre-flight check to say it will "fail via
service_error" (or similar) instead of "panic via service_error" so it
accurately reflects that CollectionError::service_error returns an Err rather
than panicking.
- Around line 102-117: The error message in shard_transfer.rs uses debug
formatting "{:?}" which wraps the already-joined peer strings in quotes; change
the format placeholders to "{}" so the joined results from
self.channel_service.peers_versions().into_iter().map(...).collect::<Vec<String>>().join(",
") and peers_addresses() appear without extra quotes when constructing the
CollectionError::service_error referencing NEW_UPDATE_ON_RESHARDING_VERSION and
channel_service; update the format string accordingly in the block that returns
Err(...) inside the resharding transfer start logic.
🧹 Nitpick comments (1)
lib/storage/src/content_manager/toc/transfer.rs (1)

76-91: Same {:?} debug-format issue as in shard_transfer.rs.

The format string on line 78 uses {:?} for the peer-version and peer-address strings, which wraps them in quotes. Use {} for cleaner output.

Also, consider extracting the repeated peer-version/address formatting logic (shared with shard_transfer.rs) into a small helper to reduce duplication.

@qdrant qdrant deleted a comment from coderabbitai Bot Feb 13, 2026
@KShivendu
KShivendu force-pushed the fix/resharding-version-gate-preflight branch from b487152 to 7dabee4 Compare February 13, 2026 14:17
@qdrant qdrant deleted a comment from coderabbitai Bot Feb 13, 2026
@timvisee

Copy link
Copy Markdown
Member

While this is correctly implemented, I do believe we should take a different path.

After careful consideration I've decided to remove the version check instead. I don't think we've a good reason to implement it in the first place, and it has been causing more trouble versus being beneficial.

See more details in #8129

@generall generall closed this Feb 14, 2026
@generall
generall deleted the fix/resharding-version-gate-preflight branch May 30, 2026 21:24
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