Repository navigation
fix(workflows): stop WorkflowDefinitionResourceIT approval flakes at the source - #36560
Conversation
…the source test_approvalOnlyWorkflowApprovesTheEntity: CreateTask commits the task row on its own JDBI connection before the Flowable command that creates the runtime user task commits. A caller that lists the open task and resolves it inside that window misses the runtime task; only metric and ontology approvals waited for it. When the runtime task committed between the variable lookup and the failure check, the resolve also surfaced the generic, non-retryable "Workflow resolution failed" 409. Any non-terminal task whose workflow instance is still running now waits (same bounded budget) for its runtime task before anything is written to the workflow, and a lookup that missed a task which exists by the time the failure is classified returns the retryable "still preparing" 409. test_upsertOfGatedFieldIsHeldForApproval: the term has a reviewer its creator is not, so the seeded GlossaryApprovalWorkflow moves it from Draft to In Review one WorkflowEventConsumer tick (~1s) after create. The test's upsert goes out ~1s after create (fixed deployment poll delay), so it regularly staged against the pre-review version and was refused as a concurrent change. The test now waits for In Review, after which the term is quiet, and asserts on the gate workflow's own task instead of any task assigned to the reviewer.
❌ 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 |
The readiness wait for a task still being committed ignored its result. On timeout the resolve went on to set taskAssignees and the rejection reason on a runtime task Flowable could not see, which WorkflowHandler.setProcessVariable drops with only a warning; if the task committed before the variable lookup, the workflow was resolved without them. Refuse with the retryable "still preparing" conflict before any workflow write instead.
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · Changing workflow resolution to wait for Flowable runtime tasks and return retryable conflicts could delay approvals when tasks remain unavailable. Stops the WorkflowDefinitionResourceIT approval flakes at the source by making resolveWorkflowTask wait for a not-yet-visible Flowable runtime task before writing to the workflow, and by having the glossary upsert test wait for the seeded review to settle. The readiness wait result is now checked, so workflow writes no longer go to a missing task, addressing that finding. No open issues found. ✅ 1 closed✅ Edge Case: Readiness wait result ignored; workflow writes still go to a missing task
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Main moved to b194104, the squash merge of PR10, after #36560. The one conflict was the endpoint count in docs/generated/api-reference.md, which both PRs change. scripts/generate_api_reference.py regenerated the doc from the merged sources. The users/generateToken row keeps main's text, because main's committed doc already differs from its source there and this PR does not change that endpoint.
…the source (#36560) * fix(workflows): stop WorkflowDefinitionResourceIT approval flakes at the source test_approvalOnlyWorkflowApprovesTheEntity: CreateTask commits the task row on its own JDBI connection before the Flowable command that creates the runtime user task commits. A caller that lists the open task and resolves it inside that window misses the runtime task; only metric and ontology approvals waited for it. When the runtime task committed between the variable lookup and the failure check, the resolve also surfaced the generic, non-retryable "Workflow resolution failed" 409. Any non-terminal task whose workflow instance is still running now waits (same bounded budget) for its runtime task before anything is written to the workflow, and a lookup that missed a task which exists by the time the failure is classified returns the retryable "still preparing" 409. test_upsertOfGatedFieldIsHeldForApproval: the term has a reviewer its creator is not, so the seeded GlossaryApprovalWorkflow moves it from Draft to In Review one WorkflowEventConsumer tick (~1s) after create. The test's upsert goes out ~1s after create (fixed deployment poll delay), so it regularly staged against the pre-review version and was refused as a concurrent change. The test now waits for In Review, after which the term is quiet, and asserts on the gate workflow's own task instead of any task assigned to the reviewer. * fix(workflows): refuse a resolve whose runtime task never became visible The readiness wait for a task still being committed ignored its result. On timeout the resolve went on to set taskAssignees and the rejection reason on a runtime task Flowable could not see, which WorkflowHandler.setProcessVariable drops with only a warning; if the task committed before the variable lookup, the workflow was resolved without them. Refuse with the retryable "still preparing" conflict before any workflow write instead.
Describe your changes:
No linked issue: this fixes two
WorkflowDefinitionResourceITtests that kept failing in the merge queue and onmain(failures listed below). Both races are removed at the source. Neither fix adds a retry or a longer timeout around a race.1.
test_approvalOnlyWorkflowApprovesTheEntity:409 Workflow resolution failed for task … on transition 'approve'Failure: MySQL + ES, global-state (merge queue for #36488).
Root cause (product race, not test-only):
CreateTaskcommits the Task row on its own JDBI connection before the Flowable command that creates the runtime user task (ACT_RU_TASK+customTaskId) commits. #31590 deliberately kept the create path synchronous, so aBpmnErrorstill aborts the workflow when the persist fails. Any caller can list the open task andPOST /resolveinside that window. Only metric and ontology approvals waited for the runtime task, so this domain approval skipped the wait. From the failing run's server log:The runtime task committed between
transformToNodeVariables(miss) and thehasActiveRuntimeTaskrecheck (hit). That skipped the existing retryable "still preparing" branch and threw the generic, non-retryable 409 instead.Fix (
TaskWorkflowHandler.resolveWorkflowTask):The workflow is still preparing task …; retry the resolution409, not the generic one. Nothing has reached the workflow at that point, so a retry is safe.Residual, stated honestly: if Flowable's commit trails the task row by more than 250 ms, the caller still gets a 409. It is now the correct, retryable one, and nothing has been written to the workflow. The observed lag was under 20 ms.
2.
test_upsertOfGatedFieldIsHeldForApproval:glossaryTerm … changed while this change was being submitted; reload and retryFailures (4 in 3 days, every engine):
Root cause (test race): the glossary has a reviewer (USER1) that the creator (admin) is not, so the term starts in
Draft. The seededGlossaryApprovalWorkflowthen moves it toIn Reviewon the nextWorkflowEventConsumertick, about 1 s after create, which bumps the version 0.1 → 0.2. The test's upsert goes out about 1 s after create, becausewaitForWorkflowDeploymenthas a fixed 1 spollDelay. That puts it in phase with the consumer tick. When the workflow's write lands between the upsert staging its base version andChangeRequestService.lockEntityAtBase, the gate correctly refuses it as a concurrent change. From the 10-29 log:The 10-27 failure has the same sequence (
14,481create →15,513tick →15,576update → PUT 409).Rejecting this upsert is consistent with the ungated path. A plain PUT reads
originalwithout a row lock and stores withoriginal.getVersion(), so the same race gives it a 412.Fix (test only): wait until the seeded review has moved the term to
In Review. The term is quiet after that: the workflow is parked on its user task, and the gated upsert never persists, so it raises no new event. The test also now asserts on the gate workflow's own task (byworkflowDefinitionId). Before, it matched any open task assigned to USER1, and the seeded review's task could satisfy that too.Origin
Neither test runs in the parallel lane.
WorkflowDefinitionResourceITruns in theglobal-statelane with@Execution(SAME_THREAD).Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
Unit tests
TaskWorkflowHandlerTestadds 3 tests:testResolveWaitsForTheRuntimeTaskItsRunningWorkflowIsStillCommittingtestRuntimeTaskAppearingAfterAMissedLookupAsksTheCallerToRetrytestRejectionIsNotWrittenToARuntimeTaskThatNeverBecameVisibleWorkflow resolution failed for task '…' on transition 'approve'. The third failed withNeverWantedButInvoked: setProcessVariable.TaskWorkflowHandlerTest23/0/0,DataAccessRequestWorkflowTest6/0/0.Backend integration tests
WorkflowDefinitionResourceIT.test_upsertOfGatedFieldIsHeldForApproval.WorkflowDefinitionResourceITin the global-state lane on MySQL + ES ran 131 tests, 0 failures, 0 errors. A green run corroborates the fix but can't prove a race is gone. The proof is the unit RED→GREEN for Create teams page similar to tags #1 and the log sequence above for Replace catalog to openmetadata #2.bffe494bbe, before the fail-fast commit):UI / Playwright
🤖 Generated with Claude Code