Repository navigation
fix: table_async pre-creates and syncs sequences for serial columns - #36
Merged
Merged
Conversation
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.
Fixes #33
Summary
pgclone.table_async()failed on any table with aserial/bigserialcolumn: the worker ranCREATE TABLE ... DEFAULT nextval('schema.tbl_id_seq')without creating the sequence first (relation "..._id_seq" does not exist). The syncpgclone.table()and the async schema path already handled this; only the single-table background path did not.bgw_clone_one_table(src/pgclone_bgw.c) now, mirroringpgclone_table():CREATE SEQUENCE IF NOT EXISTS) beforeCREATE TABLE, skipped whenconflict=ignorekeeps an existing table;setval()after the data copy, so new inserts on the target don't reuse copied ids.Both steps are idempotent, so the schema path (which already clones sequences) is unaffected.
Testing
test/test_async.shtest 9: clone abigserialtable withtable_async; asserts the job completes, 3 rows are copied, and the next insert gets id 4.Full
./test/run_all.shpasses on PG14, 15, 16, 17 and 18 (async 24/24, chaos 5/5).Notes
bigintkey; it could go back tobigserialnow, but I left it to keep this PR focused.conflictoption is not yet applied to sequences in the async single-table path (replace/renameonly act on the table), same as before this change.🤖 Generated with Claude Code