Skip to content

Fixes 33360: Cancel workflows and mark not-found after the owning delete commit - #33365

Closed
harshach wants to merge 0 commit into
mainfrom
harshach/fix-33360-workflow-cancel-post-commit
Closed

harshach wants to merge 0 commit into
mainfrom
harshach/fix-33360-workflow-cancel-post-commit

Conversation

@harshach

@harshach harshach commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #33360

Part of #32946. Stacked on #33362 (the atomicity pins), which supplies the TransactionCounter and SqlFailureProbe helpers this test uses.

A hard delete cancelled the entity's Flowable process instance and marked the entity missing in the negative cache as soon as its own inTransaction callback returned. When the delete runs inside an enclosing executeInTransaction, that callback only joins the outer transaction, so nothing had committed yet: a later rollback kept the entity row but its workflow instance was already gone and the negative cache already answered 404 for it. The comment in cleanup() described the intended behaviour; it only held when cleanup() was the outermost transaction.

Both effects now go through PostCommitActionQueue.runOrDefer, the same outbox the lifecycle dispatcher and the RDF updater already use: an enclosing unit of work drains them after its own commit and discards them on rollback, and a standalone delete still runs them immediately, so the non-nested behaviour is unchanged.

Type of change:

  • Bug fix

High-level design:

N/A — three call sites in EntityRepository (cleanup(), bulkDeleteReferencesAndRows, bulkInvalidate) wrap the existing calls in runOrDefer; no signature changes.

Tests:

Use cases covered

  • Hard delete (single and bulk) inside an enclosing transaction that commits: the workflow instance still exists inside the transaction and is cancelled after the commit.
  • Hard delete (single and bulk) inside an enclosing transaction that rolls back: the entity row survives and its workflow instance is still running.
  • Enclosing rollback leaves no negative-cache marker for the surviving entity (existing pin, now exercised with Redis).

Unit tests

Not applicable (behaviour is in the transaction boundary; covered by the integration tests below).

Backend integration tests

Ingestion integration tests

Not applicable.

Playwright (UI) tests

Not applicable.

Manual testing performed

None beyond the automated runs above.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Open workspace in Conductor

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Sep 15, 2026
@gitar-bot

gitar-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

Fixes workflow cancellation and negative cache timing by deferring both operations through PostCommitActionQueue until after the enclosing transaction commits. Hard deletes now preserve the correct entity state on rollback and cancel workflows only after successful commit, addressing the atomicity issue where nested transactions would prematurely mark entities as not-found and cancel their workflows before the delete could be rolled back.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@harshach
harshach marked this pull request as ready for review September 16, 2026 01:24
@harshach
harshach requested a review from a team as a code owner September 16, 2026 01:24
@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

harshach added a commit that referenced this pull request Sep 27, 2026
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.
harshach added a commit that referenced this pull request Sep 27, 2026
…ity (#33362)

* test: pin hard-delete, subtree and transaction-boundary atomicity

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 <[email protected]>

* fix: defer hard-delete side effects until the owning commit

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.

* fix: keep vanished database versions and RDF load out of parallel lanes

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.

* fix(cache): evict a committed cascade from Redis in one step, then drop 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 <[email protected]>
(cherry picked from commit 9ce609c)

* test(it): give the IT server the search pool sizes production ships

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.
Base automatically changed from harshach/entity-atomicity-tests to main September 27, 2026 20:18
@harshach harshach closed this Sep 27, 2026
@harshach
harshach force-pushed the harshach/fix-33360-workflow-cancel-post-commit branch from 76a5bfe to 2ed90f9 Compare September 27, 2026 21:51

This branch had an error being deployed

1 failed and 1 inactive deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hard delete cancels governance workflow instances before the enclosing transaction commits

3 participants