Skip to content

Handle when IO operations are cancelled - fix #1212 - #1292

Open
andrewjw1995 wants to merge 1 commit into
FirebirdSQL:masterfrom
andrewjw1995:handle-cancelled-io-operations
Open

andrewjw1995 wants to merge 1 commit into
FirebirdSQL:masterfrom
andrewjw1995:handle-cancelled-io-operations

Conversation

@andrewjw1995

Copy link
Copy Markdown

Fixes #1212. Some async operations accept a cancellation token and pass it through to the IO operations they perform. If the IO operations are cancelled then we may end up in one of the following states:

  • The request was not fully written to the stream
    • If we perform another operation on the stream, the request will not be interpreted correctly by the database
  • We have a complete response waiting to be read from the underlying stream
    • If we perform another operation on the stream, the responses will be out of alignment
  • The response was not fully read from the stream
    • If we perform another operation on the stream, the response will not be interpreted correctly by the client

This can be demonstrated by opening a connection, beginning a transaction, and cancelling the request immediately, which has been added as a test case.

I couldn't see an easy way to ignore frames that were interrupted or don't align to the current request/response, so when an IO operation is cancelled I have opted to treat it the same as an IO exception. The connection is marked as broken and removed from the connection pool.

TODO: I haven't checked this for compatibility with all the supported build configurations and Firebird versions. I'm hoping this is covered by the build pipeline, otherwise I will need some guidance on this.

AI usage

As per the contributor guidelines, this code was implemented by Cursor. I have reviewed it to make sure I fully understand the problem and approve of the solution that was implemented.

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.

Exception in ParseTruncSqlInfo or ParseTruncSqlInfoAsync

2 participants