Skip to content

Add query cancellation support#89

Merged
SeanTAllen merged 1 commit intomainfrom
cancel-query
Feb 12, 2026
Merged

Add query cancellation support#89
SeanTAllen merged 1 commit intomainfrom
cancel-query

Conversation

@SeanTAllen
Copy link
Member

Implements Session.cancel() for requesting cancellation of in-flight queries. PostgreSQL requires cancel requests on a separate TCP connection, so cancellation spawns a fire-and-forget _CancelSender actor that connects, sends the 16-byte CancelRequest (with the process ID and secret key from BackendKeyData), and closes. When the session uses SSLRequired, the cancel connection performs SSL negotiation before sending the request.

cancel() follows the same "never illegal" contract as close() — safe to call in any session state, no-op if no query is in flight. Cancellation is best-effort; if honored, the query's ResultReceiver gets pg_query_failed with SQLSTATE 57014.

Design: #88

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Feb 11, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 11, 2026
@SeanTAllen SeanTAllen removed the changelog - added Automatically add "Added" CHANGELOG entry on merge label Feb 12, 2026
Add Session.cancel() for best-effort cancellation of in-flight queries.
Opens a separate TCP connection via _CancelSender to send a PostgreSQL
CancelRequest (16 bytes: length, magic 80877102, pid, secret key). When
the session uses SSLRequired, the cancel connection negotiates SSL first.
Fire-and-forget — failures are silently ignored.

Group connection parameters (auth, host, service, ssl_mode) into a new
ServerConnectInfo val class. Session.create() now takes ServerConnectInfo
as its first parameter instead of individual connection arguments. This
is a breaking constructor change.

Design: #88
@SeanTAllen SeanTAllen merged commit 77b9bd2 into main Feb 12, 2026
8 checks passed
@SeanTAllen SeanTAllen deleted the cancel-query branch February 12, 2026 00:57
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants