Repository navigation
Fixes 33358: Pin hard-delete, subtree and transaction-boundary atomicity - #33362
Conversation
Add three integration tests that pin the transactional behaviour of EntityRepository on main using real commits counted through a delegating Jdbi TransactionHandler and a SqlLogger-based failure probe: - EntityTransactionBoundaryIT: nested executeInTransaction units commit once and publish post-commit actions after the outer commit, an outer failure rolls back nested writes and discards deferred actions, and custom-property replacement (removeExtensions + storeExtensions) keeps column-extension rows while committing once / rolling back together. - EntityHardDeletionAtomicityIT: deleteInternal and bulkHardDeleteSubtree commit once, roll back with an enclosing transaction (rows, extension rows and cached existence preserved), and roll back all dependent metadata when the entity-row delete fails. - EntitySubtreeAtomicityIT: bulk soft delete / restore inside an enclosing transaction rolls back rows and version history together. SqlFailureProbe injects a failure once after a matching SQL statement on the calling thread only, so background jobs are unaffected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…text> (open-metadata#33642) * Scope the JDBI test decorators on Predicate<StatementContext> Three PRs in the open-metadata#32946 stack each carry their own copy of these decorators and now collide with the versions open-metadata#33539 landed on main: CONFLICT (add/add) SqlQueryCounter.java open-metadata#33344, open-metadata#33355 CONFLICT (add/add) SqlFailureProbe.java open-metadata#33362 Their copies are not gratuitous - they scope on Predicate<StatementContext> rather than the BooleanSupplier that merged, and open-metadata#33344 and open-metadata#33355 already call the three-argument forRequests and deadlockOnce. This makes main's copy the one they call, so the dedup on rebase is a deletion rather than a rewrite. Predicate<StatementContext> is also the better answer to the review on open-metadata#33539 that forRequests was too broad. A fragment alone cannot tell the request under test apart from a concurrent one running the same SQL; the caller needs a look at each candidate statement. SqlFailureProbe.forRequests therefore returns, but requiring the caller's predicate rather than matching any in-flight request. SqlFailureProbe.deadlockOnce covers open-metadata#33344's SqlQueryCounter.deadlockOnce so EntityRepositoryGoldenIT becomes a one-line swap. Injection stays in the probe rather than moving into the counter: a counter that also throws is two jobs in one class, and the probe's one-shot claim is already a compareAndSet. 16 unit tests, both guards verified to fail without the code that satisfies them - dropping the predicate gate gives "a matching statement the predicate rejects must not be counted", and replacing the CAS with a check-then-act gives "both threads were past the guard at once ... expected: <1> but was: <2>". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Cover the request-scoped overloads, which nothing exercised Review feedback, and correct: forRequests was called by nothing but itself. The unit tests injected predicates through the package-private constructor and SqlTestDecoratorsIT only used the calling-thread ones, so the composed scope - "a request is in flight AND the caller's predicate accepts" - was the one line in these classes with no coverage. It is also the line where a regression is silent: get it wrong and every REST-driven statement is rejected, or every one is accepted, and a test supplying its own predicate would never notice. RequestLatencyContext.startRequest and clearContext are public statics, so the composition is testable without a server. Four tests, two per class: a matching statement outside any request is not counted or claimed, the same statement inside one is, and a caller predicate that rejects still wins while a request is in flight. Each half is independently guarded. Dropping the request check fails with "no request in flight, so there is nothing to attribute the statement to"; dropping the caller predicate fails with "a request is in flight but the caller's predicate rejects this statement". Verified both ways. 20 unit tests total. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Replace deadlockOnce with a scope-free deadlock() supplier Review follow-up from @manerow, and the trap is real. deadlockOnce built its probe through the calling-thread constructor, while the open-metadata#33344 factory it was meant to replace is request-scoped. Its only call site, EntityRepositoryGoldenIT, drives a PATCH over REST, so the statement runs on a Jetty worker: a calling-thread probe never fires, and the replay test goes green without ever exercising the replay. Silent false pass, in the one place whose job is to prove a deadlock is retried. A convenience that has to guess a scope will keep guessing wrong, so there is no longer one. deadlock() returns the failure shape DeadlockRetry replays and composes with either scope, which makes the mistake impossible to make by accident: new SqlFailureProbe(jdbi, fragment, deadlock()) // this thread SqlFailureProbe.forRequests(jdbi, fragment, deadlock(), mine::match) // a request Two claims in this PR were also wrong and are corrected in the description. The open-metadata#33344 call site counts as well as injects - assertEquals(2, writes.count()) - and no factory here does both, so the swap is not one line; it nests a counter around a probe. And SqlQueryCounter.afterFirst is still not provided, so open-metadata#33344 cannot delete its copy outright either. A new test pins the nesting: the probe sits outermost while both are open, closing it hands the logger back to the counter rather than the application, and the chain unwinds to the original. 21 unit tests. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * Move the composition test to the IT, where it can assert behaviour Review feedback, and correct: assertSame on the SqlLogger chain is wiring, not behaviour, and passes even if delegation stops invoking the inner decorator - the one failure it needed to catch. I had justified it by saying a real StatementContext could not be built here. That was wrong twice over. StatementContext is not final; it has a private constructor that reflection can reach. But the signature is not stable: this module resolves jdbi3-core 3.37.1, whose constructor takes (ConfigRegistry, ExtensionMethod), while 3.47.0 takes a third Type argument. A unit test built on that would break on a minor dependency bump. So the test moves to SqlTestDecoratorsIT, where real statements produce real contexts and no reflection is needed. It now asserts what one statement does to both decorators: the outer probe fires, the inner counter still sees the same statement, and once the probe is spent the counter keeps counting through it. The unit-level wiring assertion is deleted rather than kept alongside. 20 unit tests; the composition case runs in the IT lane. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
✅ Playwright Results — workflow succeededValidated commit ✅ 4613 passed · ❌ 0 failed · 🟡 7 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 39m 42s ⏱️ Max setup 4m 28s · max shard execution 19m 47s · max shard-job elapsed before upload 25m 48s · reporting 19s 🌐 219.47 requests/attempt · 2.21 app boots/UI scenario · 39.17% common-shard skew Optimization targets still in progress:
🟡 7 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Port the fix from stacked PR #33365 onto the current retryable cleanup path. Workflow cancellation and negative-cache markers now wait for the outer transaction to commit; rollback discards both actions.
Drop a history row when its required service relationship disappears during hydration. The new regression test failed before the guard and passes after it. Run the container-heavy RDF write recovery suite only in the dedicated RDF lanes, where CI still covers both database backends.
…op L1 With the Redis cache on, an async restore of a database could leave its schemas answering 404 right after the restore committed. RestoreHierarchyIT.asyncRestore_returns202AndRestoresFullHierarchy failed in 7 of the 86 postgres-elasticsearch-redis parallel-lane runs whose commit contains #33866, and in none of the 188 without it. Since #33866 the cascade's children leave Redis only after commit, in drainCacheInvalidations, one entity at a time with about ten synchronous Redis calls each. The restored root still evicts inline in EntityUpdater, so it reads as restored the moment the transaction commits, while its children keep serving their soft-deleted copies until the drain reaches them. The test polls the database, then reads a schema inside that window. The drain now evicts the committed batch in one pass: - it bumps every write epoch first, so a loader that read the pre-commit row cannot write it back after the eviction; - it deletes every entity key (id hash, by-name and reference aliases) in one DEL, split only past 1,000 keys; - it evicts L1 after that DEL, since a reader in the window copies the stale Redis entry into L1 and nothing evicted it after the commit; - it re-arms EntityCacheRepair from the commit, because the repair armed inside the transaction fires 500 ms after that eviction, which a long transaction outlives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 9ce609c)
TestSuiteBootstrap never set maxConnTotal or maxConnPerRoute, so the in-process server ran on the schema defaults: 10 connections to the single Elasticsearch host (30 total) instead of the 50/100 in conf/openmetadata.yaml. Under the parallel lane that pool stayed empty longer than connectionRequestTimeoutSecs (5 s), and requests failed with "error while performing request", Rest5Client's wrapper for the lease timeout. That is how SearchResourceIT.testEntityTypeCountsResponseFormat failed in the merge queue for #33338. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 148570d)
The Redis parallel report spent 188 seconds in this container-heavy class while the dedicated RDF lanes also ran it successfully. Gate it on enableRdf like the live-write recovery suite so CI keeps coverage without competing for Redis parallel-lane resources.
Code Review ✅ Approved🔴 High risk · Changes transaction boundaries for hard deletes and entity history, affecting stored-data integrity Pins hard-delete, subtree, and transaction-boundary atomicity with real SQL transaction and failure probes across 12 test cases, including four new workflow-cancellation scenarios. Defers hard-delete side effects and cache eviction until commit, guards against vanished service relationships during history hydration, and fixes test-load issues by restricting RDF tests to dedicated lanes. All integration tests passed with no issues found. OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #33358
Pins hard-delete, subtree, and transaction-boundary behavior with real SQL transaction and failure probes. The original 12 cases remain, and four workflow-cancellation cases now cover nested commit and rollback.
The failing CI lanes exposed additional races and test-load issues, fixed here:
RdfLiveWriteRecoveryITandRdfBlueGreenRebuildITonly in the existing MySQL and PostgreSQL/OpenSearch RDF lanes. The ordinary parallel lanes had been starting duplicate Fuseki and database containers; the Redis report showed 60-second graph-clear timeouts and broad request timeouts during that load.No schema or migration changes. PR #34059 has since merged to main. PR #33365 and PR #34077 remain open and overlap this branch.
Type of change:
High-level design:
The atomicity tests use a Jdbi
TransactionHandlerdecorator and aSqlLoggerfailure probe to assert committed and rolled-back database state. History hydration uses the existing row-by-row fallback when a required relationship disappears. Post-commit actions and cache eviction use the repository's existing deferral scope.Tests:
EntityRepositoryHistoryPageTest,DeferredCacheInvalidationTest,CachedEntityDaoAliasEvictionTest, andEntityRepositoryRestoreTest.RestoreHierarchyIT.asyncRestore_returns202AndRestoresFullHierarchy.EntityCacheWriteOrderIT,EntityUpdateLockOrderIT,EventSubscriptionResourceIT.test_concurrentEnableDisableLeavesScheduleMatchingCommittedState,RestoreHierarchyIT.asyncRestore_returns202AndRestoresFullHierarchy, andEntityHardDeletionAtomicityIT.EntityUpdateLockOrderITpassed.Ingestion integration tests:
Not applicable.
Playwright (UI) tests:
Not applicable.
Manual testing performed:
No manual tests beyond the local unit and integration runs above.
Checklist: