Skip to content

Commit 095d9b3

Browse files
framework: move the executeQueueItem deadlock TODO into its javadoc
Explain why a failed executing-msid update returns the item to the queue and what the proper fix would be, as asked in review.
1 parent bc3cde8 commit 095d9b3

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,15 @@ private int getAndResetPendingSignals(AsyncJob job) {
701701
return signals;
702702
}
703703

704+
/**
705+
* Dispatches the job behind a sync queue item.
706+
* <p>
707+
* TODO: stamping the executing management server id on the job can hit a DB deadlock. As a
708+
* temporary workaround, a failed update returns the item to the sync queue so the job is retried
709+
* on a later turn instead of failing. The proper fix is to remove the deadlock at its source, in
710+
* the locking and transaction around the sync_queue and async_job updates on dispatch, after
711+
* which this retry is no longer needed.
712+
*/
704713
protected void executeQueueItem(SyncQueueItemVO item, boolean fromPreviousSession) {
705714
AsyncJobVO job = _jobDao.findById(item.getContentId());
706715
if (job == null) {
@@ -716,11 +725,6 @@ protected void executeQueueItem(SyncQueueItemVO item, boolean fromPreviousSessio
716725
}
717726
job.setSyncSource(item);
718727

719-
//
720-
// TODO: a temporary solution to work-around DB deadlock situation
721-
//
722-
// to live with DB deadlocks, we will give a chance for job to be rescheduled
723-
// in case of exceptions (most-likely DB deadlock exceptions)
724728
try {
725729
job.setExecutingMsid(getMsid());
726730
_jobDao.update(job.getId(), job);

0 commit comments

Comments
 (0)