Repository navigation
Deduplicate external leaf partitions in the metadata table list - #126
talmacschen-arch wants to merge 2 commits into
Conversation
Under --leaf-partition-data, SplitTablesByPartitionType appends an
external (foreign-table) leaf partition to metadataTables twice on
Cloudberry / GPDB 7+:
- the external-partition branch appends it (this branch exists only to
add the _ext_part_ suffix for GPDB 6 and earlier), and
- the common GPDB7+/CBDB branch, which emits every table, appends it
again.
Both copies carry the same UniqueID, so TopologicalSort later produces a
sorted slice shorter than its input and aborts predata with:
[CRITICAL]:-Dependency resolution failed; ... This is a bug, please report.
(stack: TopologicalSort <- backupDependentObjects <- backupPredata). The
"Not yet visited" list in the verbose log is empty, which rules out a
real dependency cycle and points at a dropped, de-duplicated object.
It reproduces on any database that has an external leaf partition when
backing up with --leaf-partition-data, with or without --single-data-file.
Restrict the external-partition branch to GPDB 6 and earlier, where the
suffix is needed and the common branch does not run. On GPDB7+/CBDB the
external leaf partition is now emitted once by the common branch, exactly
like a native leaf partition.
Add a unit test asserting that an external leaf partition appears in the
metadata list exactly once under --leaf-partition-data on GPDB7+/CBDB; it
fails (length 3) before this change and passes after.
|
@liang8283 could you please help review this PR when you have a chance? Thanks! |
|
Approved. Tested this PR end to end on a live Cloudberry cluster. I built Test schema: a range-partitioned table Results
With the PR, the metadata file contains Notes
|
Address review feedback on the unit test for the external leaf partition
deduplication fix:
- Add a Cloudberry (IsCBDB) variant. The bug was reported on Cloudberry,
which takes the same GPDB7+ code path, but the original test only set a
GPDB 7.0.0 version and never exercised the IsCBDB arm.
- Add a variant with a non-empty includeList and --leaf-partition-data off.
The duplication happens in the LEAF_PARTITION_DATA || len(includeList) > 0
branch, so --include-table alone (without --leaf-partition-data) triggered
it too; this guards that path.
All three variants (GPDB7+ with --leaf-partition-data, Cloudberry with
--leaf-partition-data, GPDB7+ with a non-empty includeList) fail with length 3
before the fix and pass after it.
|
Thanks for the detailed verification and the two suggestions — both addressed:
All three variants (GPDB7+ with |
Problem
gpbackup --leaf-partition-dataaborts while writing pre-data metadata as soon as the database contains an external (foreign-table) leaf partition:It is not a real dependency cycle: the verbose log prints
Not yet visited:with no objects under it.TopologicalSortbails out in thelen(slice) != len(sorted)branch because two entries in its input share the sameUniqueID, so the sorted output ends up one element shorter than the input.The duplicate comes from
SplitTablesByPartitionType. Under--leaf-partition-data, an external leaf partition is appended tometadataTablestwice on Cloudberry / GPDB 7+:_ext_part_suffix for GPDB 6 and earlier;Reproduces on any database with an external leaf partition, with or without
--single-data-file.Fix
Restrict the external-partition branch to GPDB 6 and earlier, where the suffix is needed and the common branch does not run. On GPDB7+/CBDB the external leaf partition is now emitted once by the common branch, exactly like a native leaf partition.
Test
Added a unit test asserting that an external leaf partition appears in the metadata list exactly once under
--leaf-partition-dataon GPDB7+/CBDB. It fails (metadataTableslength 3) before the fix and passes after.Also verified end to end on a live Cloudberry 2.1.0 cluster:
gpbackup --leaf-partition-dataon a database with an external leaf partition fails withDependency resolution failedwithout this change, and completes withBackup completed successfullywith it.