Skip to content

sqle: skip dolt commit path for read-only transactions#10686

Open
DreadPirateRobertz wants to merge 1 commit intodolthub:mainfrom
DreadPirateRobertz:fix/skip-dolt-commit-readonly-tx
Open

sqle: skip dolt commit path for read-only transactions#10686
DreadPirateRobertz wants to merge 1 commit intodolthub:mainfrom
DreadPirateRobertz:fix/skip-dolt-commit-readonly-tx

Conversation

@DreadPirateRobertz
Copy link
Copy Markdown

Summary

  • Skip the expensive PendingCommitAllStaged path for read-only transactions when dolt_transaction_commit=true
  • Read-only transactions (SELECTs) go directly to commitWorkingSet, matching the behavior they'd get anyway but without staging overhead
  • Prevents empty commit attempt storm in high-frequency read workloads

Problem

When dolt_transaction_commit=true, every transaction close—including read-only SELECTs—runs PendingCommitAllStaged which calls StageAllTables and newPendingCommit. For read-only queries there are never changes to stage, so pendingCommit always returns nil and the code falls through to commitWorkingSet anyway.

In production with 6 agents polling every 30 seconds, we observed:

  • 100k+ empty commit attempts over 5 hours
  • Connection IDs reaching 717,000+
  • Server eventually returning database not found errors then crashing

Fix

Check DoltTransaction.IsReadOnly() before entering the dolt commit path. The IsReadOnly() method already exists on DoltTransaction and checks tx.tCharacteristic == sql.ReadOnly. Read-only transactions short-circuit directly to commitWorkingSet.

Test plan

  • Existing TestDoltTransactionCommitOneClient and related tests pass (write transactions still commit)
  • Read-only queries with dolt_transaction_commit=1 no longer trigger PendingCommitAllStaged

Fixes #10685

🤖 Generated with Claude Code

When dolt_transaction_commit=true, every transaction close—including
read-only SELECTs—runs PendingCommitAllStaged which stages all tables
and checks for changes. For read-only queries there are never changes,
so this work is wasted: StageAllTables runs, newPendingCommit returns
nil, and the code falls through to commitWorkingSet anyway.

In high-frequency read workloads (e.g. 6 agents polling every 30s),
this overhead compounds to 100k+ empty commit attempts and 700k+
connections over hours, eventually overwhelming the server.

Short-circuit by checking DoltTransaction.IsReadOnly() before entering
the dolt commit path. Read-only transactions go directly to
commitWorkingSet, matching the behavior they would have gotten anyway
but without the staging overhead.

Fixes dolthub#10685

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@timsehn
Copy link
Copy Markdown
Contributor

timsehn commented Mar 16, 2026

Thanks for the contribution. I've kicked off the test suite. This seems ok at first glance.

Could probably use a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dolt_transaction_commit=true causes empty commit warning storm on read-heavy workloads

3 participants