-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Avoid client result invocation ID collisions #43716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Do you have any of the perf results? This is something we can change in the future if performance is a problem right? |
@@ -42,6 +42,11 @@ public void AddInvocation(string invocationId, (Type Type, string ConnectionId, | |||
{ | |||
var result = _pendingInvocations.TryAdd(invocationId, invocationInfo); | |||
Debug.Assert(result); | |||
// Should have a 50% chance of happening once every 2.71 quintillion invocations (see UUID in Wikipedia) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣 . Are we taking bets on if we ever see this error message filed in an issue?
src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs
Outdated
Show resolved
Hide resolved
Yes, it's an internal implementation detail. Although if we wanted to do something co-operative it could be breaking if old server talks to new server. 100 threads, each thread doing 1,000,000 invocations:
|
@Pilchie for RC2. This fixes a bug when using multiple servers and the redis backplane in SignalR in combination with the new client result feature where it was possible for 2 IDs to collide which would cause the caller to hang in their app code until the cancellation token (they hopefully passed in) is canceled. |
Co-authored-by: David Fowler <[email protected]>
Approved for .NET 7 RC2. |
Fixes bullet 7 of #5280
Stephen had an interesting idea:
Unfortunately, we don't know the connection ID when
IHubProtocol
queriesIInvocationBinder
so the invocation id has to be the entire source of truth for the lookup.After doing some local perf testing, the best approach I found was to just generate a GUID and base64 encode it for every invocation. There is only one allocation, the final string, and GUID generation is still fairly cheap, the most expensive part is likely getting the random bytes.
Other alternatives considered: