Fixed wrong keys used to WATCH dependencies (#1605)

This bug has opened a lot of possible race-conditions, since the
watch-logic from redis did not fail anymore, if dependencies have been
changed in parallel.
main
th3hamm0r 3 years ago committed by GitHub
parent db445f96b2
commit c5a1ef1734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -485,7 +485,8 @@ class Job:
connection = pipeline if pipeline is not None else self.connection connection = pipeline if pipeline is not None else self.connection
if watch and self._dependency_ids: if watch and self._dependency_ids:
connection.watch(*self._dependency_ids) connection.watch(*[self.key_for(dependency_id)
for dependency_id in self._dependency_ids])
jobs = [job jobs = [job
for job in self.fetch_many(self._dependency_ids, connection=self.connection, serializer=self.serializer) for job in self.fetch_many(self._dependency_ids, connection=self.connection, serializer=self.serializer)
@ -970,7 +971,8 @@ class Job:
connection = pipeline if pipeline is not None else self.connection connection = pipeline if pipeline is not None else self.connection
if pipeline is not None: if pipeline is not None:
connection.watch(*self.dependency_ids) connection.watch(*[self.key_for(dependency_id)
for dependency_id in self._dependency_ids])
dependencies_ids = {_id.decode() dependencies_ids = {_id.decode()
for _id in connection.smembers(self.dependencies_key)} for _id in connection.smembers(self.dependencies_key)}

@ -998,7 +998,7 @@ class TestJob(RQTestCase):
pipeline.multi() pipeline.multi()
with self.assertRaises(WatchError): with self.assertRaises(WatchError):
self.testconn.set(dependency_job.id, 'somethingelsehappened') self.testconn.set(Job.key_for(dependency_job.id), 'somethingelsehappened')
pipeline.touch(dependency_job.id) pipeline.touch(dependency_job.id)
pipeline.execute() pipeline.execute()

Loading…
Cancel
Save