ServiceRegistry not updating some fields in the database correctly when dispatching jobs

Steps to reproduce

I've seen 2 cases where the database is not correctly updated:

1) When the job cannot be dispatched and is put into the dispatchPriorityList: the job's processor service is never set to null in the database.

2) When the job changes status from QUEUED to DISPATCHING: the value DISPATCHING never makes it to the database.

Note that these are not critical because #1 will "fix itself" in one of the next runs of the dispatcher and #2 will "fix itself" by the worker when it accepts the job, but it has caused DCE some trouble because of our horizontal scaling mechanism that needs to have accurate info in the database

Relevant pieces of code:

1) In the method update():

The processor service is never set to null in the database if the processing host is null.

Solution: set it to null if host is null.

2) In the method updateInternal():

The line at

originalJob = JpaJob.from(fromDb.toJob());

Makes the 'job' state be reset to QUEUED (the value from the database), probably because 'job' and 'fromDb' are actually the same instance in the EM cache? Note that, when calling the same method via public 'updateJob', the problem does not happen because the JpaJob 'job' is created from scratch and not read from the database (not associated yet with the EM?)

This behavior can be verified by running the unit tests and logging the state right before and after that line.

The solution is to remove the line (it's only for debugging purposes).


Rute Santos


Rute Santos


Incorrectly Functioning With Workaround

Tags (folksonomy)



Affects versions