test(pg_catalog): failing OID-stability regressions for #389 / #390#392
Closed
sunng87 wants to merge 1 commit into
Closed
test(pg_catalog): failing OID-stability regressions for #389 / #390#392sunng87 wants to merge 1 commit into
sunng87 wants to merge 1 commit into
Conversation
…n-contrib#389 / datafusion-contrib#390 Pooled PostgreSQL clients (DBeaver, JDBC, ...) resolve an OID on one connection and reference it on another via joins such as `pg_class WHERE relnamespace = <oid>`. Those OIDs must therefore be stable across catalog-table queries and join-consistent, and `pg_catalog` must keep its canonical namespace OID 11 (the static catalog rows reference it). These three tests assert those invariants and currently fail on master: * schema_oid_is_stable_across_pg_attribute_query A schema's OID drifts (e.g. 16385 -> 16457) after `pg_attribute` is queried, because pg_attribute replaces the shared OID cache with table-only entries, evicting the schema OID; the next pg_namespace re-assigns a different OID. * pg_class_resolves_table_via_namespace_oid The concrete symptom: after the eviction above, filtering pg_class by an earlier-resolved namespace OID matches 0 rows, so no tables are listed. * pg_catalog_namespace_keeps_fixed_oid_eleven pg_namespace assigns pg_catalog a generated OID (16385) instead of the fixed 11 that pg_type.typnamespace / pg_proc.pronamespace reference, so system-object -> namespace joins (e.g. resolving a column's data type) fail. Verified: all three FAIL on master and PASS once OIDs are derived deterministically (PR datafusion-contrib#391).
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.
What
A test-only change that adds failing regression tests reproducing the
pg_catalogOID instability described in #389 (and the related #390). No production code is changed.The intent is to provide a concrete, runnable reproduction that can be used to validate fix candidates — in particular PR #391.
Why these tests
Pooled PostgreSQL clients (DBeaver, JDBC drivers, …) resolve an OID on one connection and reference it on another via joins such as
pg_class WHERE relnamespace = <oid>. Those OIDs must therefore be:pg_class.relnamespacemust equal thepg_namespace.oida client resolved earlier).Additionally, the static catalog rows this crate ships reference the canonical
pg_catalognamespace OID 11 (e.g.pg_type.typnamespace = 11,pg_proc.pronamespace = 11), sopg_catalogmust keep that fixed OID.The tests (all currently fail on
master)masterwithschema_oid_is_stable_across_pg_attribute_querypg_attributeevicts the shared OID cache16385 != 16457pg_class_resolves_table_via_namespace_oidWHERE relnamespace = <oid>matches nothing)got 0pg_catalog_namespace_keeps_fixed_oid_elevenpg_catalogmust keep OID 1116385 != 11Root cause being captured
The dynamic catalog tables (
pg_namespace,pg_class,pg_attribute,pg_database) share one OID counter + cache, but each builder rewrites that cache differently. Notablypg_attributedoes*oid_cache = swap_cachewith table-only keys, evicting everyCatalog/SchemaOID; the nextpg_namespace/pg_classquery then re-assigns the schema a different OID via the counter, so an OID a client resolved earlier no longer matches.Verification
I confirmed all three tests fail on
masterand pass once #391 is applied.cargo fmt --checkandcargo clippy --all-features -- -D warningsare clean, so the only CI signal here is the intendedcargo testfailure.Notes
Testjob will be red on purpose. It's meant to be merged together with (or used to gate) a fix such as fix(pg_catalog): deterministic, stable OIDs for pooled clients (#389, #390) #391, not on its own.Refs #389, #390, #391.