Skip to content

Commit 69a3b8e

Browse files
committed
[IMP] queue_job: handle same uuid in duplicated db
1 parent 6792545 commit 69a3b8e

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

queue_job/jobrunner/channels.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,22 +1029,31 @@ def notify(
10291029
channel = self.get_channel_by_name(channel_name, parent_fallback=True)
10301030
job = self._jobs_by_uuid.get(uuid)
10311031
if job:
1032-
# db_name is invariant
1033-
assert job.db_name == db_name
1034-
# date_created is invariant
1035-
assert job.date_created == date_created
1036-
# if one of the job properties that influence
1037-
# scheduling order has changed, we remove the job
1038-
# from the queues and create a new job object
1039-
if (
1040-
seq != job.seq
1041-
or priority != job.priority
1042-
or eta != job.eta
1043-
or channel != job.channel
1044-
):
1045-
_logger.debug("job %s properties changed, rescheduling it", uuid)
1032+
# if db_name differs, this is likely a cloned database
1033+
if job.db_name != db_name:
1034+
_logger.warning(
1035+
"job %s exists in multiple databases (%s and %s). recreating it",
1036+
uuid,
1037+
job.db_name,
1038+
db_name,
1039+
)
10461040
self.remove_job(uuid)
10471041
job = None
1042+
else:
1043+
# date_created is invariant
1044+
assert job.date_created == date_created
1045+
# if one of the job properties that influence
1046+
# scheduling order has changed, we remove the job
1047+
# from the queues and create a new job object
1048+
if (
1049+
seq != job.seq
1050+
or priority != job.priority
1051+
or eta != job.eta
1052+
or channel != job.channel
1053+
):
1054+
_logger.debug("job %s properties changed, rescheduling it", uuid)
1055+
self.remove_job(uuid)
1056+
job = None
10481057
if not job:
10491058
job = ChannelJob(db_name, channel, uuid, seq, date_created, priority, eta)
10501059
self._jobs_by_uuid[uuid] = job

0 commit comments

Comments
 (0)