Skip to content

fix: in-flight key, staged write timeout, test seeds - #915

Merged
EVWorth merged 5 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h
Oct 29, 2026
Merged

EVWorth merged 5 commits into
mainfrom
claude/hopeful-bardeen-1k4d1h

Conversation

@EVWorth

@EVWorth EVWorth commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Follow-ups to #900, done by the implementer-rust lane.

Closes #901, #902, #903.

Changes

  • fix: in-flight query table is keyed by thread id alone #901: in-flight key.
    • InFlightMap (mas-core/src/query/in_flight.rs) is keyed by (connection_id, thread_id), so two connections whose server threads share a number no longer overwrite each other.
    • Each registration carries a token, and dropping a ticket removes only its own entry. This closes a race: a pooled connection keeps its thread id, so a guard dropping late could remove the next batch's entry.
    • The executor's separate InFlightGuard is gone; it now registers through the same ticket.
  • fix: staged writes ignore the connection's query timeout #902: staged write timeout.
    • StagedWrite::begin_in takes timeout: Option<Duration>. When the timeout expires, it sends KILL QUERY from a second connection, rolls back, and returns the same CoreError::Timeout the executor returns.
    • The MCP stage_write passes the connection's query timeout.
    • The time spent waiting for the user's answer is still bounded by its own deadline, not by this timeout.
  • chore: test containers break when their worktree is removed #903: test seeds.
    • In docker-compose.test.yml, the MySQL and MariaDB containers build images with the seed SQL copied in, so no checkout path is bind-mounted. The SSL service keeps its mounts, because its certificates are generated locally.
    • just db-reset rebuilds the images.
    • Docs updated: CONTRIBUTING.md and the integration-tests skill. The run_write row in AI_INTEGRATION.md now says the statement is bounded by the query timeout.

Tests

  • New unit tests for the in-flight key and token, and for the executor's cancel finding the right thread on each connection.
  • New live test a_staged_write_stops_at_the_connections_query_timeout. It fails after 20 s with the timeout forced off, and passes with the fix.
  • cargo fmt, clippy -D warnings, and cargo test for mas-core, sqlpilot and mas-mcp all pass.
  • cargo test -p mas-core -- --ignored: 193 passed on MySQL (13306) and 193 on MariaDB (13308).

Generated by Claude Code

Thread ids are unique per server, not across servers, so two connections
to different servers could both register thread N: the second replaced
the first, and the first finishing removed the second. Key by
(connection id, thread id), and give each registration a token so a late
drop on a reused pooled connection cannot remove a newer entry. The
executor now registers through the same ticket as the tracker.

Closes #901.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
StagedWrite::begin_in ran the agent's write without the connection's
query_timeout_secs, so a long staged write nobody cancelled held its
connection and locks unbounded. It now takes the timeout and applies it
as the executor does: on expiry it sends KILL QUERY from a second pool
connection, lets the statement end with the server's interrupted error,
rolls back and returns the executor's timeout error. The MCP workspace
passes the connection's timeout.

Closes #902.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
The shared test containers bind-mounted the seed SQL from whichever
checkout created them, so removing that checkout broke `docker start`.
MySQL 8, MariaDB 11 and the unused 5.7 service now build a small image
that copies tests/fixtures/sql/ into /docker-entrypoint-initdb.d/, and
`db-reset` rebuilds the images so a changed seed file is picked up.
The SSL service keeps its mounts: its certificates are generated
locally and are not in git.

Closes #903.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
@EVWorth
EVWorth merged commit 8e70a39 into main Oct 29, 2026
12 checks passed
@EVWorth
EVWorth deleted the claude/hopeful-bardeen-1k4d1h branch October 29, 2026 12:21
@github-actions github-actions Bot mentioned this pull request Nov 8, 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.

fix: in-flight query table is keyed by thread id alone

2 participants