Gracefully handle prepended query cancellation · Issue #4909 · npgsql/npgsql · GitHub
Skip to content

Gracefully handle prepended query cancellation #4909

Description

@vonzshik

In some cases instead of sending a query immediately, we prepend it, so we can send it with a next query. We do this for BEGIN TRANSACTION and whenever a connection is reset as it's returned to the pool.
#4907 made it so we shouldn't even send a cancellation request until we've read all of the responses for the prepended query. Instead, we can make it so the prepended query runs in the same transaction as an actual query.
This is going to require:

  • Make prepended queries use extended query protocol
  • Automatically prepare all of prepended queries on opening a connection
  • We should restore the write buffer with prepended query whenever there is an error while executing a query
  • Benchmark the change

cc @roji

Activity

  1. added this to the 8.0.0 milestone on Jan 29, 2023
  2. roji commented on Jan 30, 2023

    @roji
    Member

    Given that we merged #4907, which is about preventing prepended queries from being cancelled in the first place, I think we can put this in the backlog until we have reason to believe that the current situation is insufficient. This could happen if it's still somehow possible for a cancellation to affect prepended queries (despite the safeguards in #4907), or if we allow users to prepend custom queries and to cancel those prepended queries.

  3. modified the milestones: 8.0.0, Backlog on Jan 30, 2023
  4. added theissue type on Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions