Skip to content

[P0][bug] cancel is JS-counter only; no KILL QUERY; ARCHITECTURE §5.2 cancel_query unimplemented #281

Closed

Description

@EVWorth

Context

ARCHITECTURE §5.2 describes cancel_query, KILL QUERY <thread_id>, and event-streamed cancellation. DESIGN_REQUIREMENTS §FR-2.2.4 acceptance: "Stop button and Ctrl+. cancels the currently executing query; sends KILL QUERY to the server".

Problem

resultStore.cancelActiveQuery increments a local generation counter, which only stops the client from accepting more rows. The server-side query continues running until completion or natural timeout. A user who cancels a SELECT SLEEP(60) sees the spinner stop, but SHOW PROCESSLIST on the server shows the query still running for the full 60s. No KILL QUERY is sent, no CONNECTION_ID() is captured, no cancel_query IPC exists.

Files

  • src/stores/resultStore.ts (esp. cancel via generation counter)
  • src-tauri/crates/mas-core/src/query/executor.rs (no per-statement cancellation)
  • src-tauri/src/commands/mod.rs (no cancel_query command)
  • src-tauri/src/commands/mod.rs:157-181 (single execute_query blocks)

Repro

  1. Connect to MySQL.
  2. Run SELECT SLEEP(60);.
  3. Click Cancel.
  4. While spinner is gone within ~1s, SHOW PROCESSLIST from another session shows SELECT SLEEP(60) still running for the original session.

Expected

Clicking Cancel sends KILL QUERY <connection_id> to MySQL within 500ms; the query returns an error, the connection stays usable for the next statement.

Proposed fix

Scope L. Backend: track MySqlConnection per query, on cancel spawn tokio::spawn to execute KILL QUERY CONNECTION_ID() on a sibling connection. Expose as new cancel_query(query_handle) Tauri command. Frontend: cancelActiveQuery dispatches based on the in-flight handle. Land integration test test_cancel_long_query from TESTING_STRATEGY §4.

Acceptance

SELECT SLEEP(60) is killed within 2s of Cancel. Connection is reusable. Test passes.

Needs human verify

Yes.

Activity

  1. added
    audit
    severity/p0
    kind/bug
    kind/doc-drift
    area/editor
    on Jul 24, 2026
  2. EVWorth commented on Sep 8, 2026

    @EVWorth
    OwnerAuthor

    Fixed by #420 (and the surrounding work in that campaign). Cancel is no longer a JS counter.

    cancel_query is a registered Tauri command; the executor tracks the in-flight thread id per connection and kill_query sends KILL QUERY <thread> to the server. resultStore.ts calls it, with the comment recording exactly the point this issue makes:

    // Bumping the generation only makes this client ignore the response. The
    // statement keeps running — and holding locks — until the server is told to
    // stop, which is what cancelQuery does (#420).

    The timeout path does the same before reporting, so an abandoned statement is not left running.

    Not auto-closed because that PR referenced the issue without a closing keyword.

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

    area/editorauditkind/bugkind/doc-driftseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions