Skip to content

fix(cancel): wait for the attention ack across message boundaries - #460

Open
datlechin wants to merge 1 commit into
tiberius-rs:mainfrom
datlechin:fix/attention-ack-across-messages
Open

datlechin wants to merge 1 commit into
tiberius-rs:mainfrom
datlechin:fix/attention-ack-across-messages

Conversation

@datlechin

Copy link
Copy Markdown

Fixes #459.

  • flush_done_attention reads past end-of-message until a DONE, DONEPROC or DONEINPROC with DONE_ATTN arrives, and discards everything before it, ERROR tokens included.
  • try_unfold keeps its behavior. It now calls a private unfold(stop_at_end_of_message), which the attention drain calls with false.
  • A closed transport still fails the cancel, with UnexpectedEof. command_timeout still bounds each read.
  • Unit tests in tds::stream::token: the ack in the next message, the next request reading its own response after a cancel, and transport EOF before the ack.
  • Integration test cancel_query_after_dropping_a_running_query (tokio and smol): drops a running WAITFOR DELAY '00:00:30' after 300 ms, cancels, then runs SELECT 1.

Against mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04:

  • before: cancel_query returns Err(Protocol("Never got a DONE token acknowledging the Attention signal.")) and the next SELECT 1 returns no row
  • after: cancel_query returns Ok in 1 to 2 ms and SELECT 1 returns 1

flush_done_attention stopped at the first end-of-message. SQL Server 2022
ends a batch cancelled before it returned anything with a DONE_ERROR
message and sends the DONE_ATTN acknowledgement as the next message, so
cancel_query failed with "Never got a DONE token acknowledging the
Attention signal." and the next request read the acknowledgement.

This branch has not been deployed

No deployments
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.

cancel_query fails and leaves the connection out of step when the attention ack comes in a separate message

1 participant