harden: mix random bits into migration ID generation#125
Merged
Conversation
when SystemTime::now() is unavailable (returns Duration::ZERO via unwrap_or_default), migration IDs degenerated to just the slot number, causing collisions if the same slot was migrated more than once. mix 16 bits of randomness into the upper bits of the ID so uniqueness doesn't depend solely on clock availability.
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
…#125) when SystemTime::now() is unavailable (returns Duration::ZERO via unwrap_or_default), migration IDs degenerated to just the slot number, causing collisions if the same slot was migrated more than once. mix 16 bits of randomness into the upper bits of the ID so uniqueness doesn't depend solely on clock availability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
mixes 16 bits of randomness into migration IDs to prevent collisions when
the system clock is unavailable.
previously,
MigrationId::new()usedunwrap_or_default()onSystemTime::now(), which returnsDuration::ZEROon clock failure. thismade the ID degenerate to just the slot number (
0 ^ slot), so twomigrations of the same slot would produce identical IDs.
now the ID combines timestamp, slot, and random bits:
ts ^ (slot as u64) ^ ((noise as u64) << 48)randwas already a dependency of ember-cluster.what was tested
all 59 ember-cluster tests pass.