Skip to content

feat(connection): separate connection lanes for the agent and for jobs - #732

Merged
EVWorth merged 1 commit into
mainfrom
claude/determined-galileo-ho1kdn
Sep 25, 2026
Merged

EVWorth merged 1 commit into
mainfrom
claude/determined-galileo-ho1kdn

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Step 1 of #731.

Problem

Every live connection had one pool, and the editor, schema browsing, backups, restores and the agent (MCP) all took from it. A busy agent, or a backup holding its connection for the length of a dump, could leave the editor waiting out the acquire timeout and then failing with "pool timed out". That also broke FR-6.3.2: "a runaway agent query cannot starve the user's."

Change

Each live connection now has three lanes, each its own sqlx pool:

Lane Used by Size
Interactive editor, schema browsing, admin panel profile's "Max pool size" (unchanged)
Agent MCP run, run_ddl, explain, stage_write, and the agent's schema reads 2
Job backups and restores 2
  • The agent and job lanes open lazily. They hold no server connection until first used, and close idle connections after 60s, so a session that never runs an agent or a backup costs the server nothing extra.
  • One session setup for every lane (SET NAMES, recording thread IDs). The admin panel still recognises the agent's and backups' sessions as the app's own and refuses to kill them ([P1] [security] kill_process has no self-protection — can kill own admin connection #433).
  • Disconnect closes all three lanes.
  • Cancel is unchanged. The agent moved to its own lane, not its own executor, so the user's Cancel still stops what the agent is running, as it does today.
  • The pool-exhausted message names the lane. Only the interactive one suggests raising "Max pool size". The agent and job messages say what is running and that the editor isn't affected.
  • API: get_pool / execute / explain / SchemaInspector::new stay on the interactive lane. New: get_lane_pool, execute_in, explain_in, SchemaInspector::for_lane.

A deadlock I avoided: a backup's metadata reads stay on the interactive lane. Putting them on the job lane lets two concurrent dumps each hold one of the lane's two slots while waiting for the other, and both time out.

Verification

Run locally against MySQL 8.0 and MariaDB 11 (docker-compose.test.yml):

  • New tests/connection_lanes.rs (7 live tests):
    • with the agent and job lanes both full, the editor still runs immediately;
    • with agent queries running, the editor doesn't wait behind them;
    • a full agent lane reports as the agent's, not as "Max pool size";
    • the side lanes open nothing until they're used;
    • every lane's sessions count as the app's own;
    • disconnect closes every lane;
    • Cancel still stops an agent query.
  • They catch the bug: with the lanes temporarily pointed back at the shared pool, 4 of the 7 fail, including both starvation tests. With the change, all pass.
  • The full live suite passes serially on both servers (cargo test -p mas-core -p mas-admin -p mas-mcp -- --ignored --test-threads=1): backup, restore, staged write, explain, schema, admin and MCP.
  • cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, just test-rust and the TypeScript bindings check all pass. The bindings don't change.

Unrelated, but noticed: tests/backup_dump.rs fails when run in parallel (the default for just test-integration), because every test drops and recreates the same backup_dump_probe database. It passes with --test-threads=1. This PR doesn't touch that file.

Not in this PR

🤖 Generated with Claude Code

https://claude.ai/code/session_019uLE7rJcohc7WDPstJ7yCL


Generated by Claude Code

Every profile had one pool that the editor, schema browsing, backups,
restores and the agent (MCP) all took from, so a busy agent or a long
dump could leave the editor timing out on "pool timed out" (#731). That
also broke FR-6.3.2, which says an agent must not be able to starve the
user's connection.

Each live connection now has three lanes:
- interactive: the existing pool, sized by "Max pool size" (editor,
  schema browsing, admin);
- agent: its own pool (2) for MCP run, run_ddl, explain, stage_write and
  the agent's schema reads;
- job: its own pool (2) for backups and restores.

The agent and job lanes connect lazily and close idle connections after
60s, so a session that never uses them costs the server nothing. All
lanes share one session setup, so their threads are known as the app's
own, and disconnect closes all three. The agent keeps the shared
executor, so the user's Cancel still stops what it is running. The
pool-exhausted message now names the lane and only suggests "Max pool
size" for the interactive one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019uLE7rJcohc7WDPstJ7yCL
@EVWorth
EVWorth merged commit aebd160 into main Sep 25, 2026
12 checks passed
@EVWorth
EVWorth deleted the claude/determined-galileo-ho1kdn branch September 25, 2026 11:50
EVWorth pushed a commit that referenced this pull request Sep 25, 2026
…r's lane

main now gives the agent and backups/restores their own connection lanes
(#732), so this PR's running-query count and message are reworked on top
of that:

- The in-flight map records each query's lane, and the count covers only
  interactive-lane queries. An agent's queries hold none of the editor's
  connections and were inflating the count; a live test now shows it.
- With no editor query running, the message no longer calls it a bug in
  SQLPilot outright. It names what else holds these connections (schema
  browsing, the admin panel) and that reconnecting clears a real leak.
- The "Pool ran out of connections" warning only fires when the lane is
  actually holding connections; an empty one timing out is a server that
  went away.
- Agent and job lanes keep their own messages from #732.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019uLE7rJcohc7WDPstJ7yCL
@EVWorth EVWorth mentioned this pull request Oct 5, 2026
EVWorth added a commit that referenced this pull request Oct 5, 2026
Version bump across the three manifests and the two lockfile entries
that record the app's own version.

What 1.2.0 contains since 1.1.0:

- Each editor tab runs on its own server session, so SET @var,
  temporary tables and multi-run transactions carry across runs (#734)
- Separate connection lanes for the agent and for backups/restores, so
  neither can starve the editor; the pool-exhausted message says what
  is holding the pool (#732, #727)
- Copy button beside Expand for long cell values, such as SHOW CREATE
  TABLE (#748)
- Linux/Wayland: WebKitGTK's DMABUF renderer is turned off, for the
  black area left after resizing the window (#742)
- Tauri 2.12 on both the npm and Rust sides (#749), and the dependency
  roll-up in #740
- rustls TLS 1.3 advisory RUSTSEC-2026-0285 patched (#728)

Also the first release built with rustup in place of
dtolnay/rust-toolchain (#746), so the release jobs' toolchain step runs
on Windows and macOS for the first time.


Claude-Session: https://claude.ai/code/session_01SCNjpC4VgppHSFs7P6rkZg

Co-authored-by: Claude <[email protected]>
EVWorth added a commit that referenced this pull request Oct 20, 2026
* release: 1.3.0

Version bump across the three manifests and the two lockfile entries
that record the app's own version.

1.2.0 and 1.2.1 were bumped but never tagged, so 1.3.0 is the first
release since 1.1.0 and carries everything since it:

Connections (#731)
- Each editor tab runs on its own server session, so SET @var, SET
  SESSION, temporary tables and multi-run transactions carry over (#734)
- Each agent session, and each backup or restore, has connections of its
  own, so none of them can hold up the editor or each other (#732, #770)
- The Min/Max pool size setting and the status-bar pool counter are gone;
  connections are no longer something to size (#769)
- A "busy" error says what is busy and what to wait for (#727)

Grid
- Grid edits save on the tab's session without committing its open
  transaction (#762)
- Copy a long cell value without opening the viewer (#748)

Fixes
- Linux: WebKitGTK's DMABUF renderer is off under Wayland (#742)
- rustls for RUSTSEC-2026-0285 and RUSTSEC-2026-0346..0349 (#728, #759)
- Tauri 2.12.3, tauri-plugin-updater 2.13.3, tauri-plugin-shell 2.5.0
  (#749, #747, #758), and dependency roll-ups

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g

* fix(deps): bump rustls-webpki and webpki-roots for RUSTSEC-2026-0381..0383

rustls-webpki 0.103.16, webpki-roots and webpki-root-certs 1.0.10. The
advisories were published today: certificate verification could accept
distrusted intermediates, and the bundled roots still trusted the
distrusted emSign intermediates. cargo audit fails on all three, and a
release should not ship them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g

---------

Co-authored-by: Claude <[email protected]>
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.

2 participants