OFBIZ-13461 : Avoid async RequirementStatus FK race after createRequirement#1480
Open
diveshdut wants to merge 2 commits into
Open
OFBIZ-13461 : Avoid async RequirementStatus FK race after createRequirement#1480diveshdut wants to merge 2 commits into
diveshdut wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira ticket:
https://issues.apache.org/jira/browse/OFBIZ-13461
Summary
This fixes a timing-dependent foreign-key failure during requirement status creation.
When
createRequirementruns inside a larger transaction, its async SECA can invokecreateRequirementStatusbefore the enclosing transaction has fully committed. In that window, the newRequirementrow is not yet visible, and theRequirementStatusinsert can fail with:REQ_STTS_REQ: OFBIZ.REQUIREMENT_STATUS FOREIGN KEY(REQUIREMENT_ID) REFERENCES OFBIZ.REQUIREMENT(REQUIREMENT_ID)This was observed from the Manufacturing
Run MRPflow, but the underlying bug is in the order-side requirement status SECA behavior.Root Cause
The existing
createRequirementSECA usedevent="commit"withmode="async".That is not a safe boundary when
createRequirementparticipates in an outer transaction. The async follow-up may run before the outer transaction is committed and globally visible.This is a race condition rather than a deterministic logic error.
Changes
createRequirementstatus SECA toglobal-commit-post-runupdateRequirementstatus SECA toglobal-commitWhy
global-commit-post-runcreateRequirementStatusneeds the generatedrequirementId.global-commit-post-runensures:Tests
Added a focused regression test for the outer-transaction timing case:
RequirementStatusEcaTests.testCreateRequirementStatusAfterOuterTransactionCommitThis verifies that:
createRequirementcan run inside an outer transactionRequirementStatusis not created before commitRequirementStatusis created successfully after commit