You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grid edits should run on the editor tab's session (without committing the user's transaction) #735
Follow-up to #731 / #734. Editor tabs now run on their own server session, but grid cell edits (src/hooks/useGridSave.ts) still go through runStatement on the shared pool.
Why it matters
Locks: if the tab has an open transaction holding row locks, a grid edit to those rows waits on it until the lock wait times out. From the user's side, the edit hangs against their own tab.
Correctness: an edit made inside a tab with an open transaction belongs to that transaction. On the shared pool it commits independently of it.
The refresh after a save re-runs the query with executeQuery(connId, sql) and no session. A result read from the tab's temporary table, or one that relies on session variables, fails or differs after saving.
The hazard in the obvious fix
Grid saves wrap the batch in START TRANSACTION; …; COMMIT; so a partial failure applies nothing. On the tab's session, START TRANSACTION implicitly commits any transaction already open. Routing the same batch to the session would silently commit the user's in-progress work. Don't do that.
Design options
Know whether the session is in a transaction and choose accordingly:
no open transaction: keep START TRANSACTION … COMMIT for atomicity;
open transaction: run the edits inside it, with no wrapper, and say "Applied N changes inside your open transaction; COMMIT to keep them".
Detecting it: MariaDB has @@in_transaction, but MySQL has no equivalent. The protocol's SERVER_STATUS_IN_TRANS flag is exact, but sqlx doesn't expose OK-packet status flags. The executor could instead track transaction state per session from the statements it runs (START TRANSACTION / BEGIN / COMMIT / ROLLBACK, implicit commits by DDL, SET autocommit), which is doable but has edge cases.
Use SAVEPOINT inside an open transaction, and the existing wrapper otherwise. This needs the same detection as option 1.
Refuse grid edits while the tab has an open transaction, and tell the user to commit or roll back first. It's the simplest safe option, but still needs detection.
Whichever is chosen, the post-save refresh should re-run on the tab's session. resultStore should remember the session its current results came from (paging already does, via page.session).
Done when
grid edits from a tab land on that tab's session;
a user's open transaction is never committed implicitly by a grid save;
the refresh after a save reads from the same session;
Activity