Skip to content

IBX-12530: Stopped truncating fixture tables inside a transaction - #825

Closed
Steveb-p wants to merge 1 commit into
6.0from
ibx-12530-fixture-fk-checks
Closed

Steveb-p wants to merge 1 commit into
6.0from
ibx-12530-fixture-fk-checks

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Sep 13, 2026

Copy link
Copy Markdown
Contributor
🎫 Issue IBX-12530

Description:

FixtureImporter truncates every table a fixture mentions before re-inserting rows. TRUNCATE is
DDL, and inside a transaction both supported databases punish it:

  • MySQL/MariaDB commit implicitly, ending the transaction dama/doctrine-test-bundle wraps each
    test in and discarding its savepoints. The suite loses isolation for the rest of the run and
    reports SAVEPOINT DAMA_TEST does not exist, with rows missing between tests.
  • PostgreSQL refuses it outright for any table a foreign key references, and aborts the whole
    transaction — so the DELETE written here as a fallback could never actually run either. It
    failed too, with current transaction is aborted, and that is all the caller ever saw.

Nothing is gained by TRUNCATE there anyway: the rows are a fixture, not a real data set. Outside
a transaction it is still used, so the fast path is unchanged where it is safe.

Detecting the transaction needs the driver connection rather than Connection::isTransactionActive()
— DAMA opens its transaction underneath DBAL, so Doctrine's nesting counter reports zero while the
session is inside one. This was confirmed the hard way: a first attempt using Doctrine's counter was
inert, and cannot truncate a table referenced in a foreign key constraint kept appearing.

For QA:

Verified against ibexa/dashboard, whose integration suite could not finish bootstrapping on either
database. With this change all four of its PostgreSQL and MySQL integration jobs pass.

@Steveb-p
Steveb-p force-pushed the ibx-12530-fixture-fk-checks branch 4 times, most recently from b913c35 to caa21b6 Compare September 18, 2026 12:39
TRUNCATE is DDL. MySQL and MariaDB commit implicitly on it, which ends the transaction the test
suite wraps each test in and discards its savepoints - the suite then loses isolation, rows
disappear between tests and DAMA's rollback fails with "SAVEPOINT DAMA_TEST does not exist".
PostgreSQL refuses it for any table a foreign key references and aborts the whole transaction,
so the DELETE written here as a fallback could never actually run: it failed too, with "current
transaction is aborted", which is all the caller ever got to see.

Detecting the transaction needs the driver connection rather than Connection::isTransactionActive():
dama/doctrine-test-bundle opens its transaction underneath DBAL, so Doctrine's nesting counter
reports zero while the session is inside one.

Outside a transaction TRUNCATE is still used, so the fast path is unchanged where it is safe.
@Steveb-p
Steveb-p force-pushed the ibx-12530-fixture-fk-checks branch from caa21b6 to 48cbdd3 Compare September 18, 2026 14:35
@Steveb-p Steveb-p changed the title IBX-12530: Suspended foreign key checks while importing a fixture IBX-12530: Stopped truncating fixture tables inside a transaction Sep 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@Steveb-p Steveb-p closed this Sep 18, 2026
@Steveb-p
Steveb-p deleted the ibx-12530-fixture-fk-checks branch September 18, 2026 16:09
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.

1 participant