-
Notifications
You must be signed in to change notification settings - Fork 4.1k
pgwire: replace deadline and connection polling with separate goroutine #25585
Description
From #25328 (comment):
Rather than setting a deadline on the read and periodically polling whether the session is cancelled, we could fire up another goroutine which blocks on ctx.Done() and then closes the connection. I recall there was some reason this approach wasn't taken when this code was written, but taking another look it isn't clear to me why it wouldn't work. This would be a bit more involved of a change, so I'm fine with the current PR as a stop-gap solution.
The reason we use a deadline approach in the first place is because:
even when the context is canceled, you still might need to use the connection to send back an error (e.g. sending an AdminShutdownError when draining).
However, this can be worked around by half closing the connection. That is, we can close the connection for reading but still write to it. See TCPConn.CloseRead.
Jira issue: CRDB-5704