Repository navigation
fix(governance): persist workflow task stage after Flowable commit to stop spurious 409 - #31590
Conversation
❌ PR checklist incompleteThis 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 |
✅ Playwright Results — workflow succeededValidated commit ✅ 579 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 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) 49m 45s ⏱️ Max setup 2m 57s · max shard execution 18m 36s · max shard-job elapsed before upload 21m 46s · reporting 4s 🌐 210.33 requests/attempt · 2.80 app boots/UI scenario · 2.87% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
… stop spurious 409
A /resolve for the next user-task transition can arrive while the workflow is
still running an async automatedTask between two user tasks (e.g. Collate's
DataAccessRequest workflow: TaskReview --approve--> PolicyAgent(async) -->
ApprovedAccess --markAsGranted-->).
CreateTask.notify() runs as a Flowable TaskListener inside the command that
creates the next runtime user task, but on the update path it persisted the
entity's workflowStageId / availableTransitions via taskRepository.update(...),
which commits on JDBI's own connection mid-command — milliseconds before Flowable
commits the ACT_RU_TASK row and the customTaskId variable. A client polling
availableTransitions could see the next transition (e.g. markAsGranted) advertised
and resolve into a not-yet-committed runtime task: the resolve found no task,
completed with no variables, and the outgoing gateway condition
${<node>_result == '<transition>'} evaluated an unbound variable — a
FlowableException surfaced to the caller as a spurious 409 under concurrency.
Defer the update-path persist to a Flowable post-commit transaction listener
(TransactionState.COMMITTED) so the entity's stage/availableTransitions are only
advanced once the runtime task they advertise is durable. This is non-blocking:
the write is reordered, never waited on — no Thread.sleep, no polling, no thread
blocked. COMMITTED listeners run synchronously inside the command's commit before a
synchronous taskService.complete() returns, so synchronous stage advances still
reflect the new stage in their response; on rollback the listener never fires and
the entity correctly keeps the prior stage. The create path stays synchronous so a
persist failure still aborts the workflow via BpmnError.
Also guard resolveWorkflowTask against a null namespace map (treat as a failed
resolve) so a genuinely stale resolve never completes a task with no variables.
Verified against the Collate DAR integration tests (DarStatusGroupIT,
DataAccessRequestValidationIT, DataAccessRequestIT), which exercise the real
PolicyAgent async node: the two CI-failing tests pass and the full DAR suite is
green across repeated runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4d6bdc2 to
a5371ce
Compare
…le-version conflict Address PR review: the deferred (post-commit) update-path persist used the task snapshot read at the start of CreateTask.notify() as the update baseline. If the stored task advanced between that read and the post-commit callback, updating against the stale snapshot would fail the optimistic-version check and leave the entity one stage behind the already-committed Flowable runtime. Re-read the committed row inside the listener and update against it. On a hard persist failure the entity self-heals on the next stage advance (which re-reads the current task). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Addressing the review findings: On the current commit (post-commit-listener approach):
Stale (reviewed the earlier |
Address PR review: replace the source-text assertions with a behavioural test of the ordering seam. Mock only the Flowable TransactionContext (framework boundary) and assert the observable behaviour of registerPostCommitPersist: the persist does not run inline, it is registered as a TransactionState.COMMITTED listener, it runs exactly once when that listener fires, it runs inline when there is no active transaction context, and a persist failure in the listener is contained (Flowable has already committed — nothing to roll back). registerPostCommitPersist is now package-private for the test. Full workflow behaviour remains covered by the Collate DAR integration tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Follow-up on the test finding: |
|
Changes have been cherry-picked to the 2.0 branch. |
… stop spurious 409 (#31590) * fix(governance): persist workflow task stage after Flowable commit to stop spurious 409 A /resolve for the next user-task transition can arrive while the workflow is still running an async automatedTask between two user tasks (e.g. Collate's DataAccessRequest workflow: TaskReview --approve--> PolicyAgent(async) --> ApprovedAccess --markAsGranted-->). CreateTask.notify() runs as a Flowable TaskListener inside the command that creates the next runtime user task, but on the update path it persisted the entity's workflowStageId / availableTransitions via taskRepository.update(...), which commits on JDBI's own connection mid-command — milliseconds before Flowable commits the ACT_RU_TASK row and the customTaskId variable. A client polling availableTransitions could see the next transition (e.g. markAsGranted) advertised and resolve into a not-yet-committed runtime task: the resolve found no task, completed with no variables, and the outgoing gateway condition ${<node>_result == '<transition>'} evaluated an unbound variable — a FlowableException surfaced to the caller as a spurious 409 under concurrency. Defer the update-path persist to a Flowable post-commit transaction listener (TransactionState.COMMITTED) so the entity's stage/availableTransitions are only advanced once the runtime task they advertise is durable. This is non-blocking: the write is reordered, never waited on — no Thread.sleep, no polling, no thread blocked. COMMITTED listeners run synchronously inside the command's commit before a synchronous taskService.complete() returns, so synchronous stage advances still reflect the new stage in their response; on rollback the listener never fires and the entity correctly keeps the prior stage. The create path stays synchronous so a persist failure still aborts the workflow via BpmnError. Also guard resolveWorkflowTask against a null namespace map (treat as a failed resolve) so a genuinely stale resolve never completes a task with no variables. Verified against the Collate DAR integration tests (DarStatusGroupIT, DataAccessRequestValidationIT, DataAccessRequestIT), which exercise the real PolicyAgent async node: the two CI-failing tests pass and the full DAR suite is green across repeated runs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(governance): re-read task before post-commit persist to avoid stale-version conflict Address PR review: the deferred (post-commit) update-path persist used the task snapshot read at the start of CreateTask.notify() as the update baseline. If the stored task advanced between that read and the post-commit callback, updating against the stale snapshot would fail the optimistic-version check and leave the entity one stage behind the already-committed Flowable runtime. Re-read the committed row inside the listener and update against it. On a hard persist failure the entity self-heals on the next stage advance (which re-reads the current task). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * test(governance): make CreateTask post-commit persist test behavioural Address PR review: replace the source-text assertions with a behavioural test of the ordering seam. Mock only the Flowable TransactionContext (framework boundary) and assert the observable behaviour of registerPostCommitPersist: the persist does not run inline, it is registered as a TransactionState.COMMITTED listener, it runs exactly once when that listener fires, it runs inline when there is no active transaction context, and a persist failure in the listener is contained (Flowable has already committed — nothing to roll back). registerPostCommitPersist is now package-private for the test. Full workflow behaviour remains covered by the Collate DAR integration tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> (cherry picked from commit 08e2e7c)
|
Failed to cherry-pick changes to the 1.13 branch. |
Code Review ✅ Approved 4 resolved / 4 findingsDefers update-path task stage persistence to a Flowable post-commit transaction listener and adds a null-namespace guard to resolve workflow tasks, addressing stale-version conflicts and spurious 409 errors. No open issues found. ✅ 4 resolved✅ Performance: Interrupt turns bounded wait into a busy-loop hammering the DB
✅ Performance: Resolve path can block a request thread up to ~5s (double wait)
✅ Edge Case: Post-commit persist failure leaves entity/runtime divergent
✅ Quality: Regression test asserts on source text, not behavior
OptionsDisplay: compact → Showing less information. 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
A
/resolvefor the next user-task transition can arrive while the workflow is still running an asyncautomatedTaskbetween two user tasks. The canonical case is Collate's DataAccessRequest workflow:CreateTask.notify()runs as a FlowableTaskListenerinside the command that creates the next runtime user task, but on the update path it persisted the entity'sworkflowStageId/availableTransitionsviataskRepository.update(...)— which commits on JDBI's own connection mid-command, milliseconds before Flowable commits theACT_RU_TASKrow and thecustomTaskIdprocess variable.A client polling
availableTransitionscould therefore see the next transition (e.g.markAsGranted) advertised and resolve into a not-yet-committed runtime task: the resolve found no task, completed with no variables, and the outgoing gateway condition${<node>_result == '<transition>'}evaluated an unbound variable →FlowableException→ surfaced to the caller as a spurious 409 CONFLICT under concurrency.Fix
TransactionState.COMMITTED) so the entity's stage /availableTransitionsare only advanced once the runtime task they advertise is durable.Thread.sleep, no polling, no thread blocked.COMMITTEDlisteners run synchronously inside the command's commit before a synchronoustaskService.complete()returns, so synchronous stage advances (e.g. incident userTask→userTask) still reflect the new stage in their response. On rollback the listener never fires and the entity correctly keeps the prior stage.BpmnError.TaskWorkflowHandler.resolveWorkflowTaskguards against anullnamespace map (treats it as a failed resolve) so a genuinely stale resolve never completes a task with no variables.Type of change
How was this tested
CreateTaskPostCommitPersistTest— source-level regression guard that the update-path persist is deferred to aTransactionState.COMMITTEDlistener (not persisted inline), that it never blocks (Thread.sleep-free), and that the null-namespace guard is present.DarStatusGroupIT,DataAccessRequestValidationIT,DataAccessRequestIT), which run the real PolicyAgent async node: the two CI-failing tests (darListEndpointMultiSelectStatus,testDarClose_onGranted_returns400) pass, and the full DAR suite is green across repeated concurrent runs.Checklist
🤖 Generated with Claude Code
Greptile Summary
The PR defers update-path task persistence until Flowable commits and prevents task completion with a null namespaced-variable map.
Confidence Score: 4/5
The PR does not yet appear safe to merge because a terminal resolve can still update the task entity directly while its Flowable process is asynchronously advancing and has not materialized the next runtime task.
The null-map guard prevents completing a Flowable task without variables, but a null lookup also makes the active-task check false and leaves the existing terminal direct-resolution fallback reachable while the workflow may still be live.
Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java
Important Files Changed
Sequence Diagram
Reviews (4): Last reviewed commit: "test(governance): make CreateTask post-c..." | Re-trigger Greptile
Context used: