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(): https://github.com/opencast/opencast/blob/9646abd232b08705dbbf868dcea5a390097a56c1/modules/serviceregistry/src/main/java/org/opencastproject/serviceregistry/impl/ServiceRegistryJpaImpl.java#L1128-L1132

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(): https://github.com/opencast/opencast/blob/9646abd232b08705dbbf868dcea5a390097a56c1/modules/serviceregistry/src/main/java/org/opencastproject/serviceregistry/impl/ServiceRegistryJpaImpl.java#L1006-L1031

The line at https://github.com/opencast/opencast/blob/9646abd232b08705dbbf868dcea5a390097a56c1/modules/serviceregistry/src/main/java/org/opencastproject/serviceregistry/impl/ServiceRegistryJpaImpl.java#L1013:

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).

Status

Assignee

Rute Santos

Reporter

Rute Santos

Severity

Incorrectly Functioning With Workaround

Tags (folksonomy)

None

Components

Affects versions

5.0
7.0
6.0

Priority

Minor
Configure