Seed ThreadLocalRandom from a cryptographic source - #8377
Merged
Aaronontheweb merged 3 commits intoJul 16, 2026
Merged
Conversation
TickCount-based seeding gives simultaneously-started processes correlated per-thread random streams, affecting gossip target selection, backoff/circuit-breaker jitter, and shuffles. This was observed as identical system UIDs across MNTR node processes.
Member
Author
|
Deep review found the original regression test did not exercise the reported cross-process defect: two threads in one process already received distinct Interlocked-incremented seeds before this change, and the array comparison did not provide useful coverage of the seed source. Commit 5d95348 isolates the cryptographic seed draw, tests that repeated draws do not collapse to TickCount-style deterministic behavior, makes the ThreadLocal field readonly, and removes the inaccurate claim that random collisions are impossible. Focused result: 2/2 passed; Akka warnings-as-errors build clean. |
Aaronontheweb
commented
Jul 16, 2026
Aaronontheweb
left a comment
Member
Author
There was a problem hiding this comment.
LGTM, we should probably replace ThreadLocalRandom with Random.Shared in the near future anyway.
Aaronontheweb
enabled auto-merge (squash)
July 16, 2026 14:11
Aaronontheweb
disabled auto-merge
July 16, 2026 15:31
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this pull request
Oct 2, 2026
* Seed ThreadLocalRandom from a cryptographic source TickCount-based seeding gives simultaneously-started processes correlated per-thread random streams, affecting gossip target selection, backoff/circuit-breaker jitter, and shuffles. This was observed as identical system UIDs across MNTR node processes. * Harden ThreadLocalRandom seed regression coverage (cherry picked from commit 86fdbb3)
Aaronontheweb
added a commit
to Aaronontheweb/akka.net
that referenced
this pull request
Oct 3, 2026
* Seed ThreadLocalRandom from a cryptographic source TickCount-based seeding gives simultaneously-started processes correlated per-thread random streams, affecting gossip target selection, backoff/circuit-breaker jitter, and shuffles. This was observed as identical system UIDs across MNTR node processes. * Harden ThreadLocalRandom seed regression coverage (cherry picked from commit 86fdbb3)
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
ThreadLocalRandomseeded its per-thread base fromEnvironment.TickCount. Processes started in the same millisecond (orchestrator-launched cluster nodes, MNTR node processes) share that base, so corresponding threads across those processes draw identical random streams. This has already manifested as identical system UIDs across MNTR node processes.Replaces the
TickCountbase with a base drawn fromRandomNumberGenerator.GetInt32. The per-threadInterlocked.Incrementscheme is unchanged; only the shared base is now cryptographically random. Public API is unchanged.Test plan
dotnet build src/core/Akka -warnaserror- cleandotnet test src/core/Akka.Tests --filter FullyQualifiedName~Akka.Tests.Utilx3 - 91/91 passing each rundotnet test src/core/Akka.API.Tests --filter FullyQualifiedName~ApproveCore- zero API churn