Repository navigation
fix(transaction): commit a COPY only once its checkpoint can run - #1507
Merged
adsharma merged 1 commit intoNov 4, 2026
Merged
Conversation
COPY FROM and CREATE INDEX on a large ART skip the WAL and are durable only through the checkpoint after their commit, which needs every other write transaction gone. A checkpoint that timed out waiting for another writer was downgraded to a warning, so the statement reported success and its rows were lost if the process stopped before a later checkpoint. Such a transaction now waits for the other write transactions to leave before it commits, and new write transactions wait at BEGIN until its commit and checkpoint finish. If another writer is still open after the checkpoint wait timeout, the transaction is rolled back and nothing is committed. A second such transaction reaching commit while one waits is rolled back at once, since the first is waiting for it to leave. A forced checkpoint that still fails after the commit throws CheckpointException again.
Contributor
|
Liveness: |
This was referenced Nov 5, 2026
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.
Description
Follow-up to #1435.
COPY FROMandCREATE INDEXon a large ART don't write their data to the WAL. They become durable only through the checkpoint that runs right after their commit, and that checkpoint needs every other write transaction gone. With multi-writer mode on by default, b6649b7 turned a checkpoint that timed out waiting for another writer into a warning on stderr, and the statement reported success. ACOPYrun beside another connection's open transaction then lost all of its rows if the process stopped before a later checkpoint: reopening the database without a checkpoint showed an empty table.This makes a statement that needs the forced checkpoint wait for the other write transactions to finish before it commits, instead of after:
BEGINuntil its commit and checkpoint finish, so none can start in between and block the checkpoint. Read-only transactions aren't held.COMMITthat fails, and the whole transaction is rolled back.A forced checkpoint that still fails after the commit, for example on an I/O error, throws
CheckpointExceptionagain, as before b6649b7. The message now says to runCHECKPOINTrather than the statement, since the statement's rows are already committed.The trade-off is that a
COPYor largeCREATE INDEXcan now fail when another write transaction stays open longer than the checkpoint wait timeout (5 s by default), and new write transactions are held for up to that long while it waits. Before b6649b7 the sameCOPYalso failed, but only after it had committed, so running it again tried to insert rows that were already there.Types of changes
Checklist
Not needed: the on-disk format is unchanged.