Skip to content

pgwire: replace deadline and connection polling with separate goroutine #25585

@nvb

Description

@nvb

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

Metadata

Metadata

Assignees

Labels

A-sql-pgwirepgwire protocol issues.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions