Skip to content

Commit

Permalink
[JBPM] fix performance regression
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Dec 9, 2020
1 parent 26f026b commit 62cb09e
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,13 @@ private void registerUpdateSync() {
}
}


private static ThreadLocal<String> txParent = new ThreadLocal<>();

private class TransactionInterceptor extends AbstractInterceptor {



public TransactionInterceptor() {
setNext(new PseudoClockRunner());
}
Expand All @@ -582,15 +587,13 @@ public RequestContext execute( Executable executable, RequestContext context ) {
PersistenceContext persistenceContext = jpm.getApplicationScopedPersistenceContext();
// We flag the current persistence runner
final String DROOLS_PARENT_RUNNER = "DROOLS_PARENT_RUNNER";
boolean isParentRunner = txm.getResource(DROOLS_PARENT_RUNNER) == null;
boolean isParentRunner = txParent.get() == null; //first time ?
if (isParentRunner) {
txParent.set(DROOLS_PARENT_RUNNER);
}
boolean transactionOwner = false;

try {
transactionOwner = txm.begin();
if (isParentRunner) {
txm.putResource(DROOLS_PARENT_RUNNER, TRUE);
}

persistenceContext.joinTransaction();

initExistingKnowledgeSession( sessionInfo.getId(),
Expand All @@ -617,6 +620,10 @@ public RequestContext execute( Executable executable, RequestContext context ) {
rollbackTransaction(t1, transactionOwner);
}
throw new RuntimeException("Wrapped exception see cause", t1);
} finally {
if(isParentRunner) {
txParent.remove();
}
}

return context;
Expand Down

0 comments on commit 62cb09e

Please sign in to comment.