Skip to content

roachtest: add pg_dump round-trip compatibility test #167543

Draft
rafiss wants to merge 4 commits intocockroachdb:masterfrom
rafiss:pgdump-roachtest
Draft

roachtest: add pg_dump round-trip compatibility test #167543
rafiss wants to merge 4 commits intocockroachdb:masterfrom
rafiss:pgdump-roachtest

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Apr 5, 2026

Add a weekly roachtest that validates pg_dump round-trip compatibility
with CockroachDB. The test builds pg_dump from PostgreSQL source
(REL_17_4), creates a representative schema in a source database,
dumps it with pg_dump --schema-only using the pg_dump_compatibility
session variable, restores into a target database via psql, dumps
again, and compares the two outputs.

Known deviations are tracked via an expected-diff baseline file in
testdata, following the same pattern as the pg_regress roachtest. The
current baseline captures one known issue: pg_dump emits a view
before the table it depends on, causing the view to be lost during
restore.

The test covers enum types, tables with various column types,
constraints, secondary indexes (including partial and covering),
foreign keys, sequences, views, comments, multi-schema objects,
and default expressions.

Resolves: #167442
Epic: CRDB-28751

Release note: None

@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented Apr 5, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Apr 5, 2026

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

It looks like your PR touches SQL parser code but doesn't add or edit parser tests. Please make sure you add or edit parser tests if you edit the parser.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

rafiss and others added 4 commits May 7, 2026 10:37
Add a weekly roachtest that validates pg_dump round-trip compatibility
with CockroachDB. The test builds pg_dump from PostgreSQL source
(REL_17_4), creates a representative schema in a source database,
dumps it with `pg_dump --schema-only` using the `pg_dump_compatibility`
session variable, restores into a target database via psql, dumps
again, and compares the two outputs.

Known deviations are tracked via an expected-diff baseline file in
testdata, following the same pattern as the pg_regress roachtest. The
current baseline captures one known issue: pg_dump emits a view
before the table it depends on, causing the view to be lost during
restore.

The test covers enum types, tables with various column types,
constraints, secondary indexes (including partial and covering),
foreign keys, sequences, views, comments, multi-schema objects,
and default expressions.

Resolves: cockroachdb#167442
Epic: CRDB-28751

Release note: None
Harden the pg_dump roachtest in three ways:

1. **Expanded schema coverage**: Add identity columns, generated/computed
   columns, composite primary keys, self-referencing foreign keys,
   multi-level view dependencies (view → view → table), and tables with
   multiple foreign keys. These exercise pg_dump code paths that the
   original test didn't cover.

2. **Content verification**: Add `verifyDumpContent` which checks that
   the source dump contains expected patterns (CREATE TABLE, CREATE VIEW,
   FOREIGN KEY, COMMENT ON, etc.). This catches cases where pg_dump
   silently omits objects from both dumps — a gap the round-trip diff
   comparison cannot detect. Patterns can be marked `knownFailure` to
   log warnings without failing the test, providing visibility into
   known compatibility gaps. Currently FK constraints and comments are
   known-missing.

3. **Restore error tracking**: Add `parseRestoreErrors` to extract ERROR
   lines from psql stderr and write them to a `restore_errors.txt`
   artifact. Previously, restore errors were invisible when psql exited 0.

Update the expected.diff baseline for the identity column round-trip
issue (pg_dump emits nextval() referencing a sequence before the sequence
is created, causing restore failure).

Epic: CRDB-28751

Release note: None

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
Create 3100 filler tables in a throwaway database before creating the
test schema, pushing descriptor IDs into the range of PostgreSQL
catalog OIDs (1247–6104). This verifies that the tableoid remapping in
pg_dump_compatibility mode doesn't cause confusion when user table
descriptor IDs collide with standard PG catalog OIDs like pg_class
(1259) or pg_type (1247).

Epic: CRDB-28751

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@rafiss rafiss force-pushed the pgdump-roachtest branch from 16384ef to a4f4f72 Compare May 7, 2026 14:39
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented May 7, 2026

Detected infrastructure failure (matched: self-hosted runner lost communication with the server). Automatically rerunning failed jobs. (run link)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

roachtest: add nightly pg_dump compatibility test using PostgreSQL's test suite

2 participants