-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ConnectCallback's context.InitialRequestMessage has misleading lifetime (not tied to the Connection) #66989
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsThe As a result, any access of
|
I assume this is due to the change in .NET 6 that enables a different connection to service the request if one becomes available before this connection has been established? |
Exactly. |
In general that change would seem to have broken the notion of "InitialRequestMessage", since it's not necessarily. That's still the request that made the system decide to inject another connection, but it's not necessarily the first one to use it, or even use it at all. |
Triage:
|
Note that this isn't only specific to headers, but anything exposed on Headers are the most likely to show up as exceptions, but the ownership of the object is a problem for all the properties. Worst-case, a user may be reusing the request object entirely (something we don't guard against via |
Team discussion Options:
Note: Also We are leaning towards [3]. |
Continued triage:
|
The mitigation around headers (concurrent reads) has been merged (#68115) and I've updated the docs to mention that request message reuse is discouraged (dotnet/dotnet-api-docs#8224). Moving to future. |
Team triage:
|
Can gRPC keep using it? Or could the request's property bag be provided in the callback? I need some way to pass in state to the callback from the request. |
You could suppress the obsoletion warning and use it, but the question is if it behaves how you're expecting it to. The What are you using the properties for in gRPC? |
@JamesNK ping on Miha's question above ... |
The callback is here: The values are set onto the request here: Basically, this handler changes the request URI based on the result from load balancing, and also sets some properties on the request's options. The properties in the request options are only used if the callback is run, and they're used to establish the new connection stream. |
Passing read-only information to ConnectCallback through |
One problematic case for
Do you mean literally Using the request itself still has issues w.r.t. object lifetimes. If the caller wanted to reuse requests in between (including clearing |
I think current users of
I originally meant this, but we can consider introducing a new
Isn't this something we explicitly discourage? |
The same concern applies to |
The
ConnectCallback
is provided with aSocketsHttpConnectionContext
that includes theInitialRequestMessage
.By the time the callback runs, the initial request may have already been completed and returned to the user, or it is being sent by a different connection. That is, a different thread may be accessing the headers while the callback is running.
As a result, any access of
InitialRequestMessage
's headers is problematic.Related: #61798, #65379
The text was updated successfully, but these errors were encountered: