test(postgresql): move DatabaseWithTablesTests off the shared public schema (weasel#407) - #410
Merged
Merged
Conversation
…schema (weasel#407)
detect_and_apply_schema_changes failed intermittently in full-suite runs,
roughly 1 in 3-6 locally, with either
XX000: could not open relation with OID 659774
at Table.readIndexesAsync ... Table.FetchExisting.cs:365
or
42P01: relation "public.dwt_contacts" does not exist
It never failed with the class run in isolation, so it was cross-collection
interference rather than anything wrong with the test itself.
The class is [Collection("integration")] and ResetSchema() resets
"integration", but the tables were created in "public", which nothing here
isolates and which at least nine other test files also write to. xUnit
serialises a collection against itself but runs different collections in
parallel, so another collection could drop objects in "public" mid-test:
directly, giving 42P01, or between the pg_index catalog row being read and
the relation being opened, giving the OID error.
Create the tables in "integration" instead, so ResetSchema() actually
covers them. Same change for the sibling dwt_users and dwt_people, which had
the same exposure.
Verified: 12 consecutive full-suite runs on the configuration that used to
fail (net10.0, case-sensitive), zero failures.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #407.
Symptom
DatabaseWithTablesTests.detect_and_apply_schema_changesfailed intermittently in full-suite runs, ~1 in 3–6 locally, with either:Reproduced on clean
master. It never failed with the class run in isolation (8 filtered runs), so it was cross-collection interference, not a bug in the test's own logic.Cause
The class is
[Collection("integration")]andResetSchema()resets itsSchemaName—"integration"— but the tables were created inpublic:Nothing here isolates
public, and at least nine other test files also write to it:PostgresqlMigratorTests,create_and_teardown_schemas,Tables/TableTests,Tables/IndexDefinitionTests,Tables/creating_tables_in_database,Tables/ForeignKeyTests,Tables/Indexes/FullTextIndexDefinitionTests,Functions/FunctionBodyTests,Views/ViewTests.xUnit serialises a collection against itself but runs different collections in parallel, so another collection could drop objects in
publicmid-test:42P01pg_indexcatalog row being read and the relation being opened →XX000: could not open relation with OID, the classic Postgres catalog raceChange
Create the tables in
integration, soResetSchema()actually covers them. Same for the siblingsdwt_usersanddwt_people, which had identical exposure. A class-level comment records why, so they don't drift back.Test-only — no product code touched.
Verification
12 consecutive full-suite runs on the exact configuration that used to fail (net10.0, case-sensitive), zero failures — against a prior rate of roughly 1 in 3–6.
Note
The broader hazard remains: tests sharing
publicacross parallel collections is a standing source of this failure mode. Worth deciding separately whetherpublicshould be off-limits to anything that creates or drops objects.🤖 Generated with Claude Code