-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JBPM-10088] Removing timers when rollback #2365
Conversation
@@ -100,10 +100,6 @@ public JobHandle scheduleJob(Job job, JobContext ctx, Trigger trigger) { | |||
public boolean removeJob(JobHandle jobHandle) { | |||
String uuid = ((EjbGlobalJobHandle) jobHandle).getUuid(); | |||
final Timer ejbTimer = getEjbTimer(getTimerMappinInfo(uuid)); | |||
if (TRANSACTIONAL && ejbTimer == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timer might be expired (getEJBTimer will return null) and we still want try to remove it just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
4b24ea1
to
b7e701c
Compare
@@ -186,7 +186,12 @@ private interface Transaction<I> { | |||
|
|||
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) | |||
public <I> void transaction(Transaction<I> operation, I item) throws Exception { | |||
operation.doWork(item); | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transaction should be rollback if there is any exception
@@ -146,30 +139,17 @@ private TimerMappingInfo getTimerMappinInfo(long processInstanceId, long timerId | |||
} | |||
|
|||
private TimerMappingInfo getTimerMappingInfo(Function<EntityManager, List<TimerMappingInfo>> func) { | |||
InternalRuntimeManager manager = ((GlobalTimerService) globalTimerService).getRuntimeManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using CMT, I do not think we need to create a different transaction here anymore
@@ -222,7 +201,7 @@ public JobHandle buildJobHandleForContext(NamedJobContext ctx) { | |||
|
|||
@Override | |||
public boolean isTransactional() { | |||
return TRANSACTIONAL; | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is not point in keeping the variable. CMT is always transactional.
public | ||
void setEnvironment(RuntimeEnvironment environment) { | ||
if (environment instanceof SimpleRuntimeEnvironment) { | ||
((SimpleRuntimeEnvironment)environment).addToEnvironment("IS_TIMER_CMT", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to tell GlobalJpaTimerJobInsance that we are using CMT
@@ -111,7 +113,7 @@ public void executeTimerJob(Timer timer) { | |||
Thread.currentThread().interrupt(); | |||
} | |||
try { | |||
invokeTransaction(this::executeTimerJobInstance, timerJobInstance); | |||
executeTimerJobInstance(timerJobInstance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to create a new transaction here. Also PersistableRunner is on the middle, handling the transaction itself. Because that transaction is not longer usable once PersistableRunner commits it, we need to create a new one to execute recoverTimerJob.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before this was provoking an exception at setRollbackOnly call in the new end-2-end test, because there was no transaction
03bf3b4
to
00e98d7
Compare
...jbpm-persistence-jpa/src/main/java/org/jbpm/persistence/timer/GlobalJpaTimerJobInstance.java
Outdated
Show resolved
Hide resolved
459a47a
to
3bba9a7
Compare
SonarCloud Quality Gate failed. 0 Bugs 71.4% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
jenkins do fdb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, works fine with jbpm-playground samples, awesome work @fjtirado !
Just add the labels for backporting before merge
* [JBPM-10088] Removing timers when rollback * [JBPM-10088] Dealing with transactions in different way * [JBPM-10088] Set to no transactional * Revert "[JBPM-10088] Set to no transactional" This reverts commit 61b735b. * [JBPM-10088] Setting CMT property in environment * [JBPM-10088] REmoving new transaction created while querying during rollback * [JBPM-10088] Do not create transaction for regular timer task * [JBPM-10088] Sonar comments * [JBPM-10088] Some test failed * [JBPM-10088] Removing unneeded casting
* [JBPM-10088] Removing timers when rollback * [JBPM-10088] Dealing with transactions in different way * [JBPM-10088] Set to no transactional * Revert "[JBPM-10088] Set to no transactional" This reverts commit 61b735b. * [JBPM-10088] Setting CMT property in environment * [JBPM-10088] REmoving new transaction created while querying during rollback * [JBPM-10088] Do not create transaction for regular timer task * [JBPM-10088] Sonar comments * [JBPM-10088] Some test failed * [JBPM-10088] Removing unneeded casting
* [JBPM-10088] Removing timers when rollback * [JBPM-10088] Dealing with transactions in different way * [JBPM-10088] Set to no transactional * Revert "[JBPM-10088] Set to no transactional" This reverts commit 61b735b. * [JBPM-10088] Setting CMT property in environment * [JBPM-10088] REmoving new transaction created while querying during rollback * [JBPM-10088] Do not create transaction for regular timer task * [JBPM-10088] Sonar comments * [JBPM-10088] Some test failed * [JBPM-10088] Removing unneeded casting Co-authored-by: Francisco Javier Tirado Sarti <[email protected]>
* [JBPM-10088] Removing timers when rollback * [JBPM-10088] Dealing with transactions in different way * [JBPM-10088] Set to no transactional * Revert "[JBPM-10088] Set to no transactional" This reverts commit 61b735b. * [JBPM-10088] Setting CMT property in environment * [JBPM-10088] REmoving new transaction created while querying during rollback * [JBPM-10088] Do not create transaction for regular timer task * [JBPM-10088] Sonar comments * [JBPM-10088] Some test failed * [JBPM-10088] Removing unneeded casting Co-authored-by: Francisco Javier Tirado Sarti <[email protected]>
Quality Gate passedIssues Measures |
@martinweiler Can you try your reproducer for JBPM-8688 with this one? Thanks in advance.