Skip to content
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

Merged
merged 10 commits into from
Dec 1, 2023
Merged

Conversation

fjtirado
Copy link
Contributor

@fjtirado fjtirado commented Nov 16, 2023

@martinweiler Can you try your reproducer for JBPM-8688 with this one? Thanks in advance.

@@ -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) {
Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@fjtirado fjtirado force-pushed the JBPM-10088 branch 4 times, most recently from 4b24ea1 to b7e701c Compare November 16, 2023 12:33
@@ -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 {
Copy link
Contributor Author

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

@fjtirado fjtirado marked this pull request as ready for review November 16, 2023 19:08
@@ -146,30 +139,17 @@ private TimerMappingInfo getTimerMappinInfo(long processInstanceId, long timerId
}

private TimerMappingInfo getTimerMappingInfo(Function<EntityManager, List<TimerMappingInfo>> func) {
InternalRuntimeManager manager = ((GlobalTimerService) globalTimerService).getRuntimeManager();
Copy link
Contributor Author

@fjtirado fjtirado Nov 22, 2023

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;
Copy link
Contributor Author

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

@fjtirado fjtirado Nov 22, 2023

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.

Copy link
Member

@gmunozfe gmunozfe Nov 23, 2023

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

@fjtirado fjtirado force-pushed the JBPM-10088 branch 4 times, most recently from 03bf3b4 to 00e98d7 Compare November 22, 2023 15:50
@fjtirado fjtirado force-pushed the JBPM-10088 branch 4 times, most recently from 459a47a to 3bba9a7 Compare November 23, 2023 10:40
Copy link

sonarcloud bot commented Nov 24, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

71.4% 71.4% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@gmunozfe
Copy link
Member

jenkins do fdb

Copy link
Member

@gmunozfe gmunozfe left a 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

@fjtirado fjtirado added backport-7.67.x Generate backport PR for 7.67.x branch backport-7.67.x-blue Generate backport PR for 7.67.x-blue branch labels Nov 28, 2023
@fjtirado fjtirado merged commit 80efbc1 into kiegroup:main Dec 1, 2023
9 of 10 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 1, 2023
* [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
github-actions bot pushed a commit that referenced this pull request Dec 1, 2023
* [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
fjtirado added a commit that referenced this pull request Jan 10, 2024
* [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]>
fjtirado added a commit that referenced this pull request Jan 10, 2024
* [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]>
@fjtirado fjtirado changed the title [JBPM-10088] Removing timers when rollback [JBPM-8688] Removing timers when rollback Mar 4, 2024
Copy link

sonarcloud bot commented Mar 4, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@fjtirado fjtirado changed the title [JBPM-8688] Removing timers when rollback [JBPM-10088] Removing timers when rollback Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-7.67.x Generate backport PR for 7.67.x branch backport-7.67.x-blue Generate backport PR for 7.67.x-blue branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants