Reshard copy: skip catalogued NOT NULL constraints (PG 18 sources)#924
Merged
Conversation
A real cnpg->ext reshard failed at the constraint-replay step: apply constraint ducklake_data_file_data_file_id_not_null on ducklake_data_file: ERROR: syntax error at or near "NOT" (SQLSTATE 42601) The cnpg shards run PG 18, which catalogues NOT NULL as pg_constraint rows (contype 'n'); pg_get_constraintdef renders them as "NOT NULL <col>", whose ALTER TABLE ... ADD CONSTRAINT form only parses on PG 18+ — an older external-RDS target rejects it. They are also fully redundant: the copier's CREATE TABLE already applies column-level NOT NULL from pg_attribute.attnotnull. Skip contype 'n' in the replay. Not caught by the ext->cnpg e2e because that direction copies FROM an older-PG RDS, which has no 'n' rows; the PG-18-source direction (cnpg->ext) is unit-only per the resharding contract.
Test Impact PlanDeterministic summary of how this PR changes tests, CI runners, and coverage-risk signals. Summary
Signals
Coverage risk: likely reduced Warnings
|
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.
A real cnpg→external reshard on mw-dev failed at the constraint replay:
(The rollback worked as designed — org back on the shard, unblocked.)
Cause: the cnpg shards run PG 18, which catalogues NOT NULL as
pg_constraintrows (contype 'n', new in 18).pg_get_constraintdefrenders them asNOT NULL <col>, and theALTER TABLE … ADD CONSTRAINT … NOT NULL <col>form only parses on PG 18+ — the older external-RDS target rejects it. They're also fully redundant: the copier'sCREATE TABLEalready applies column-levelNOT NULLfrompg_attribute.attnotnull.Fix: skip
contype 'n'in the replay (shouldReplayConstraint), with a unit test pinning the replayed set (p/u/f/c/x yes, n no).Why e2e missed it: the ext→cnpg positive path copies from an older-PG RDS (no 'n' rows exist there); the PG-18-source direction (cnpg→ext) is unit-only per the resharding contract — the harness has no RDS password, which the start API requires ephemerally.
🤖 Generated with Claude Code