Skip to content

Commit

Permalink
https://github.com/atomikos/transactions-essentials/issues/217
Browse files Browse the repository at this point in the history
Error "Recursion detected"
In ProcessA, Service A.a1(operation) remotecall Service B.b1 in
ProcessB, and B.b1 remotecall ServiceA.a2 in ProcessA

transaction failed with "recursive detect" exception when TM in ProcessA
call prepare to itself
  • Loading branch information
martinaubele committed Jun 16, 2024
1 parent 6c786d5 commit 460e537
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public void addExtent(Extent extent) throws SysException, IllegalArgumentExcepti
if (!ct.getTid().equals(extent.getParentTransactionId())) {
throw new IllegalArgumentException("The supplied extent is for a different transaction: found " + extent.getParentTransactionId()+ " but expected " + ct.getTid());
}
for (Participant p : extent.getParticipants()) {
String rootId = ct.getCompositeCoordinator().getRootId();
// detect rccursive call
if (rootId != null && p.getURI().endsWith(rootId))
return;
}
ct.getExtent().add(extent);
Stack<Participant> participants = extent.getParticipants();
for (Participant p : participants) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public int prepare() throws RollbackException, HeurHazardException, HeurMixedExc
if (LOGGER.isDebugEnabled()) {
LOGGER.logDebug("Calling prepare on " + getURI());
}
// happens for recursive calls
if (cascadeList.isEmpty()) {
return Participant.READ_ONLY;
}
try {
int result = client.target(uri).request()
.buildPost(Entity.entity(cascadeList, HeaderNames.MimeType.APPLICATION_VND_ATOMIKOS_JSON))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ public int prepare () throws RollbackException,
// If a recursive prepare re-enters, then it will see a voting state -> reject.
// Note that this may also avoid some legal prepares, but only rarely
if ( getState ().equals ( TxState.PREPARING ) )
throw new RollbackException ( "Recursion detected" );
return Participant.READ_ONLY;
//throw new RollbackException ( "Recursion detected" );

int ret = Participant.READ_ONLY + 1;
synchronized ( fsm_ ) {
Expand Down

0 comments on commit 460e537

Please sign in to comment.