Skip to content

Commit

Permalink
[private-bamoe-issues-1326] [DBACLD-109939] BBVA duplicate timer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Dec 5, 2023
1 parent d0e6241 commit bb73b6c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,20 @@ public static class GlobalJobHandle extends DefaultJobHandle

private static final long serialVersionUID = 510l;

private transient boolean valid;
public GlobalJobHandle(long id) {
super(id);
this.valid = true;
}


public boolean isValid() {
return valid;
}

public void setValid(boolean valid) {
this.valid = valid;
}

public Long getTimerId() {
JobContext ctx = this.getTimerJobInstance().getJobContext();
if (ctx instanceof SelfRemovalJobContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ public void internalSchedule(TimerJobInstance timerJobInstance) {
Timer timer = timerService.createSingleActionTimer(expirationTime, config);
TimerHandle handle = timer.getHandle();
((GlobalJpaTimerJobInstance) timerJobInstance).setTimerInfo(handle);
logger.debug("Timer scheduled {} on {} scheduler service", timerJobInstance);
String timerServiceId = ((EjbGlobalJobHandle) timerJobInstance.getJobHandle()).getDeploymentId();
logger.debug("Timer scheduled {} on {} scheduler service", timerJobInstance, timerServiceId);
((GlobalJpaTimerJobInstance) timerJobInstance).setExternalTimerId(getPlatformTimerId(timer));
if (useLocalCache) {
localCache.putIfAbsent(((EjbGlobalJobHandle) timerJobInstance.getJobHandle()).getUuid(), timerJobInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public boolean removeJob(JobHandle jobHandle) {
// this situation needs to be avoided as it should not happen
return false;
}
((GlobalJobHandle) jobHandle).setValid(false);
JtaTransactionManager tm = (JtaTransactionManager) TransactionManagerFactory.get().newTransactionManager();
try {
tm.registerTransactionSynchronization(new TransactionSynchronization() {
Expand All @@ -117,9 +118,10 @@ public void afterCompletion(int status) {
if (status == TransactionManager.STATUS_COMMITTED) {
logger.debug("remove job {} after commited", jobHandle);
scheduler.removeJob(jobHandle, ejbTimer);
} else {
((GlobalJobHandle) jobHandle).setValid(true);
}
}

});
logger.debug("register tx to remove job {}", jobHandle);
return true;
Expand Down Expand Up @@ -257,8 +259,7 @@ public void setInterceptor(SchedulerServiceInterceptor interceptor) {

@Override
public boolean isValid(GlobalJobHandle jobHandle) {

return true;
return jobHandle.isValid();
}

protected String getJobName(JobContext ctx, long id) {
Expand Down

0 comments on commit bb73b6c

Please sign in to comment.