Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash if expires_ms is negative #447

Open
danieleds opened this issue Apr 22, 2024 · 0 comments
Open

crash if expires_ms is negative #447

danieleds opened this issue Apr 22, 2024 · 0 comments

Comments

@danieleds
Copy link

danieleds commented Apr 22, 2024

Here:

arq/arq/connections.py

Lines 162 to 174 in 9d7944b

enqueue_time_ms = timestamp_ms()
if _defer_until is not None:
score = to_unix_ms(_defer_until)
elif defer_by_ms:
score = enqueue_time_ms + defer_by_ms
else:
score = enqueue_time_ms
expires_ms = expires_ms or score - enqueue_time_ms + self.expires_extra_ms
job = serialize_job(function, args, kwargs, _job_try, enqueue_time_ms, serializer=self.job_serializer)
pipe.multi()
pipe.psetex(job_key, expires_ms, job)

If expires_ms is negative (score - enqueue_time_ms + self.expires_extra_ms < 0) then we get a crash:

redis.exceptions.ResponseError: Command # 1 (PSETEX arq:job:677f11b1fbaf40c48b656cf35054851b -2505600000 ��g}�(�t�N�f��XXXX��a��)XXXXXXX����k�}��et���>��u.) of pipeline caused error: ("invalid expire time in 'psetex' command",)

This can happen when setting a negative _defer_by, as suggested here to give the job higher priority.

If the user specified a negative _defer_by, the way the score is computed should change so that the expires_ms is never negative or zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant