Bug 1463352 - Bundle deployment sometimes fails with message "Unable to store Trigger with name: '<timestamp>' and group: 'org.rhq.enterprise.server.scheduler.jobs.BundleDeploymentStatusCheckJob', because one already exists with this identification."
Bundle deployment sometimes fails with message "Unable to store Trigger with ...
Status: NEW
Product: RHQ Project
Classification: Other
Component: Provisioning (Show other bugs)
4.12
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On:
Blocks: 1463351
  Show dependency treegraph
 
Reported: 2017-06-20 11:31 EDT by bkramer
Modified: 2017-06-20 11:31 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description bkramer 2017-06-20 11:31:35 EDT
Description of problem:

Bundle deployment sometimes fails with the error like:

********************************************************
... INFO  [org.quartz.core.JobRunShell] (RHQScheduler_Worker-5) Job org.rhq.enterprise.server.scheduler.jobs.BundleDeploymentStatusCheckJob.39199 threw a JobExecutionException: : org.quartz.JobExecutionException: Could not schedule the bundle deployment completion check job for BundleDeployment[id=39199, name=Deployment [3] of Version [3.0.0] to [my_platform]. Upgrade from Version [2.0.0]]. [See nested exception: org.quartz.ObjectAlreadyExistsException: Unable to store Trigger with name: '1497219902994' and group: 'org.rhq.enterprise.server.scheduler.jobs.BundleDeploymentStatusCheckJob', because one already exists with this identification.]
	at org.rhq.enterprise.server.scheduler.jobs.BundleDeploymentStatusCheckJob.execute(BundleDeploymentStatusCheckJob.java:97) [rhq-server.jar:4.12.0.JON330GA-redhat-8]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-1.6.5.jar:1.6.5]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) [quartz-1.6.5.jar:1.6.5]
Caused by: org.quartz.ObjectAlreadyExistsException: Unable to store Trigger with name: '1497219902994' and group: 'org.rhq.enterprise.server.scheduler.jobs.BundleDeploymentStatusCheckJob', because one already exists with this identification.
********************************************************

The trigger name in the above message is a timestamp meaning that if multiple deployments were created at the same time, there is a chance that a duplicate trigger for a different job was created. Our code confirms this - BundleDeploymentStatusCheckJob.execute:

**********************************************************
064     @Override
065     public void execute(JobExecutionContext context) throws JobExecutionException {
066         BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
067         SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
068 
069         Subject overlord = subjectManager.getOverlord();
070 
071         PageList<BundleDeployment> deployments = bundleManager.findBundleDeploymentsByCriteria(overlord,
072             getCriteriaFromContext(context));
073 
074         if (deployments.size() > 0) {
075             BundleDeployment bundleDeployment = deployments.get(0);
076             SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
077             JobDetail jobDetail = context.getJobDetail();
078 
079             BundleDeploymentStatus bundleDeploymentStatus = bundleManager.determineBundleDeploymentStatus(bundleDeployment.getId());
080             if (bundleDeploymentStatus.isTerminal()) {
081                 // delete this job, we've assigned a final status
082                 try {
083                     context.setResult(bundleDeploymentStatus); // Return status to possible listeners
084                     scheduler.deleteJob(jobDetail.getName(), jobDetail.getGroup());
085                 } catch (SchedulerException e) {
086                     throw new JobExecutionException("Could not delete the bundle deployment completion check job for "
087                         + bundleDeployment + ".", e);
088                 }
089             } else {
090                 // try again in 10s
091                 try {
092                     Trigger trigger = QuartzUtil.getFireOnceOffsetTrigger(jobDetail, 10000L);
093                     // just need a trigger name unique for this job
094                     trigger.setName(String.valueOf(System.currentTimeMillis()));
095                     scheduler.scheduleJob(trigger);
096                 } catch (SchedulerException e) {
097                     throw new JobExecutionException(
098                         "Could not schedule the bundle deployment completion check job for " + bundleDeployment + ".",
099                         e);
100                 }
101             }
102         }
103     }
**********************************************************

where "trigger.setName(String.valueOf(System.currentTimeMillis()));". 


Version-Release number of selected component (if applicable):
RHQ 4.12

How reproducible:
Sometimes

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Note You need to log in before you can comment on or make changes to this bug.