sqle: skip dolt commit path for read-only transactions#10686
Open
DreadPirateRobertz wants to merge 1 commit intodolthub:mainfrom
Open
sqle: skip dolt commit path for read-only transactions#10686DreadPirateRobertz wants to merge 1 commit intodolthub:mainfrom
DreadPirateRobertz wants to merge 1 commit intodolthub:mainfrom
Conversation
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]>
Contributor
|
Thanks for the contribution. I've kicked off the test suite. This seems ok at first glance. Could probably use a test. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PendingCommitAllStagedpath for read-only transactions whendolt_transaction_commit=truecommitWorkingSet, matching the behavior they'd get anyway but without staging overheadProblem
When
dolt_transaction_commit=true, every transaction close—including read-only SELECTs—runsPendingCommitAllStagedwhich callsStageAllTablesandnewPendingCommit. For read-only queries there are never changes to stage, sopendingCommitalways returns nil and the code falls through tocommitWorkingSetanyway.In production with 6 agents polling every 30 seconds, we observed:
database not founderrors then crashingFix
Check
DoltTransaction.IsReadOnly()before entering the dolt commit path. TheIsReadOnly()method already exists onDoltTransactionand checkstx.tCharacteristic == sql.ReadOnly. Read-only transactions short-circuit directly tocommitWorkingSet.Test plan
TestDoltTransactionCommitOneClientand related tests pass (write transactions still commit)dolt_transaction_commit=1no longer triggerPendingCommitAllStagedFixes #10685
🤖 Generated with Claude Code