Skip to content

feat(grid): save grid edits on the editor tab's session without committing its transaction - #762

Merged
EVWorth merged 1 commit into
mainfrom
claude/hopeful-bardeen-1k4d1h
Oct 18, 2026
Merged

EVWorth merged 1 commit into
mainfrom
claude/hopeful-bardeen-1k4d1h

Conversation

@EVWorth

@EVWorth EVWorth commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Closes #735. Remaining item 1 of #731.

Problem

Grid cell edits (src/hooks/useGridSave.ts) went through runStatement on the shared pool, not the editor tab's session:

  • an edit to rows the tab had locked in an open transaction waited on the tab itself until innodb_lock_wait_timeout;
  • an edit made inside the tab's open transaction committed independently of it;
  • the refresh after a save re-ran the query with no session and the connection's default database, so a result read from a temporary table or session variable failed or changed.

Moving the existing START TRANSACTION; …; COMMIT; batch onto the session would have been worse: START TRANSACTION implicitly commits a transaction already open, so it would silently commit the user's work.

Change

A new apply_grid_edits command (mas-core/src/query/grid_edits.rs) holds the tab's one connection for the whole save, so nothing else from the tab runs between the check and the edits. It first asks whether a transaction is open:

Session state Save runs as On failure
no transaction START TRANSACTION … COMMIT explicit ROLLBACK, so a failed save never leaves the tab inside a transaction
transaction open SAVEPOINT … RELEASE SAVEPOINT inside it, uncommitted ROLLBACK TO SAVEPOINT: undoes only the save, and the user's work and transaction stay as they were
can't tell nothing applied, returns null frontend falls back to the shared pool as before

This combines the issue's options 1 and 2: edits join the open transaction, and a savepoint keeps the save atomic inside it.

Detecting the transaction. The check assigns the next transaction's isolation level its current session value: SET @@transaction_isolation = @@session.transaction_isolation. MySQL and MariaDB both refuse this with ER 1568 inside a transaction, and outside one it changes nothing. I tried SET TRANSACTION READ WRITE first: it detects transactions the same way, but it overrides a session's READ ONLY setting for the next transaction, so a save could get past a read-only session. A test covers that.

Tested against MySQL 8.0 and MariaDB 11:

State Read as
no transaction none
START TRANSACTION with nothing run open
BEGIN then a SELECT open
autocommit = 0, then a write open
autocommit = 0, nothing run yet none (nothing to lose)
after COMMIT; after a DDL implicit commit none

Frontend. resultStore now keeps resultSource (connection, database, tab session) for the results on screen. Only MySQL tabs carry a session. useGridSave saves through runGridEdits, which records history with origin grid like runStatement does. The refresh then reads on the same session and database. A save inside an open transaction tells the user: "Applied N change(s) inside your open transaction. COMMIT to keep them, or ROLLBACK to undo them."

Tests

  • Live (mas-core/tests/grid_edits.rs, 6 tests, passing on MySQL 8.0 and MariaDB 11):
    • commits when no transaction is open;
    • doesn't commit an open transaction, and a ROLLBACK undoes the user's insert and the edit together;
    • a failed save inside a transaction undoes only itself;
    • a failed save leaves no transaction open;
    • an edit to rows the tab has locked no longer waits on the tab;
    • the check keeps a session's READ ONLY setting.
  • Mutation check: forcing the save to ignore an open transaction (the naive fix) fails the three transaction tests.
  • Unit: useGridSave.test.ts (6 tests: routing, the open-transaction message, fallback when the session can't tell, a result with no session, a result on another connection, a failed save), and resultStore tests for resultSource.
  • Existing suites:
    • full live integration suite on MySQL; editor_sessions also on MariaDB;
    • Rust unit tests: 262 passed;
    • vitest: everything passes except src/__tests__/main.test.tsx, which hits a hook timeout in my container with or without this change;
    • ResultsGrid.browser.test.tsx: 120 passed;
    • clippy -D warnings, rustfmt, dprint, eslint, and the vi.mock path check are clean.
  • src/lib/bindings.ts is regenerated with just bindings, not hand-edited.

Notes

  • If the server rolls back the user's whole transaction mid-save, as MySQL does on a deadlock (ER 1213), the savepoint goes with it. The user sees the server's deadlock error, which says to restart the transaction.
  • If the session can't tell (for example, a server without @@transaction_isolation), the save falls back to the old batch on the shared pool. Behaviour there is unchanged.

Generated by Claude Code

…tting its transaction (#735)

Grid edits went to the shared pool, so an edit to rows the tab had locked
waited on the tab itself, an edit made inside the tab's open transaction
committed independently of it, and the refresh after a save read from a
connection without the tab's temporary tables or session variables.

Sending the old START TRANSACTION ... COMMIT batch to the session instead
would have committed the user's open transaction implicitly. A new
apply_grid_edits command holds the tab's one connection for the whole save
and first asks whether a transaction is open:

- none open: START TRANSACTION ... COMMIT, with an explicit ROLLBACK on
  failure so a failed save never leaves the tab inside a transaction;
- one open: SAVEPOINT ... RELEASE inside it, so the edits join the user's
  transaction uncommitted and a failure rolls back only the save;
- cannot tell: nothing is applied and the frontend falls back to the
  shared pool as before.

The question is asked by reassigning the next transaction's isolation level
its current session value: MySQL and MariaDB both refuse that with ER 1568
inside a transaction, and outside one it changes nothing. Unlike SET
TRANSACTION READ WRITE it keeps a session's READ ONLY setting. Verified on
MySQL 8.0 and MariaDB 11.

The result store now remembers the session and database its results were
read on, so the save and the refresh after it use them. A save inside an
open transaction says so and tells the user to COMMIT or ROLLBACK.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
@EVWorth
EVWorth merged commit 122b87a into main Oct 18, 2026
12 checks passed
@EVWorth
EVWorth deleted the claude/hopeful-bardeen-1k4d1h branch October 18, 2026 14:30
@EVWorth EVWorth mentioned this pull request Oct 20, 2026
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.

Grid edits should run on the editor tab's session (without committing the user's transaction)

2 participants