Skip to content

fix: keep Case 3 filter adoption in memory, never write it back - #1042

Open
ydixken wants to merge 2 commits into
dimitri:mainfrom
ydixken:fix/case3-filter-writeback
Open

fix: keep Case 3 filter adoption in memory, never write it back#1042
ydixken wants to merge 2 commits into
dimitri:mainfrom
ydixken:fix/case3-filter-writeback

Conversation

@ydixken

@ydixken ydixken commented Aug 21, 2026

Copy link
Copy Markdown

Any filter-checked command invoked without --filters on a filtered work dir (Case 3: list progress, list table-parts, compare, or clone when the filters file is simply not passed) adopts the stored filter type, then persists its own re-serialization via catalog_update_filters. That serialization comes from the command's empty SourceFilters, so the pattern arrays are dropped: {"type":"SOURCE_FILTER_TYPE_EXCL","exclude-schema":["audit"]} degrades to {"type":"SOURCE_FILTER_TYPE_EXCL"}. Every later clone --filters on that work dir (or its live workers) then fails the setup comparison and exits 12; one bare list progress poisons the work dir for good.

The write-back exists so forked workers, which inherit the adopted type with empty relation lists, pass the comparison on re-entry (1089e6c). This patch keeps that property without mutating the catalog: the stored record becomes immutable, and the comparison recognizes the adopted signature, the stored type plus whatever extension filtering the parent carried (extension filters contribute no filter type, so an extension-only --filters file also adopts). list progress is additionally marked filter-agnostic (skipFilterCheck) like the sentinel commands.

Regression: tests/filtering now runs list table-parts, list progress, a filterless clone, and an extension-only clone between a filtered clone and its --resume rerun, asserting the stored filtering survives each; tests/pagila-standby keeps covering the filterless-clone worker re-entry path.

Fixes #1038.

The exclude work directory is now opened by a list command, by a filterless
clone and by a clone filtered on extensions alone, each of which used to
overwrite its stored filters and leave the next clone --filters exclude.ini
failing with a filtering mismatch (dimitri#1038). Both clones fork workers that
re-enter the catalog setup check, which is the path the fix has to keep
working.
A command that opens a work directory created with filters, but is invoked
without them, adopted the catalog's stored filter type and then wrote its own
serialization back to source.db. That serialization carries the type and
nothing else, so the stored pattern lists were lost and every later --filters
command in that directory failed with a filtering mismatch. This was never
confined to a handful of commands: any filter-checked command run without the
stored filters reaches case 3, and a plain list tables exits 0 and prints its
usual output while truncating the record. The write-back was there so that
forked workers, which inherit the adopted type with empty relation lists and
whatever extension filtering their parent had, would not hit the case 2
conflict; case 2 now recognizes that adopted signature and lets them through,
which leaves the stored record immutable for every filterless caller at once.
list progress skips the filter check outright, as the other filter-agnostic
commands already do.

Fixes dimitri#1038
ydixken added a commit to ydixken/pgcopydb-operator that referenced this pull request Aug 21, 2026
The two filed pgcopydb issues now point at the PRs that fix them,
dimitri/pgcopydb#1042 and dimitri/pgcopydb#1041.

PostgreSQL's 2026-08-13 minor releases (CVE-2026-6471) load only the
output plugins named in output_plugin_libraries, which defaults to
pgoutput and test_decoding. A source on those releases refuses
spec.follow.plugin: wal2json until an admin adds it and reloads, so the
prerequisites carry the rule and troubleshooting carries the new error
string.
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.

list progress rewrites the stored filtering of a filtered work dir, breaking concurrent and resumed clone --filters runs

1 participant