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

Non unique schedule redis lock key #42

Closed
marcowindt opened this issue Jun 18, 2024 · 8 comments · Fixed by #44
Closed

Non unique schedule redis lock key #42

marcowindt opened this issue Jun 18, 2024 · 8 comments · Fixed by #44

Comments

@marcowindt
Copy link

We ran into the issue that Redis lock key for job scheduler is non-deterministic across nodes when using Jason encode, since the key is based on the MD5 hash of the serialized job. Right now the order of the keys in json object has to be the same which is not always the case, resulting in different keys for the same job.

Using a custom serializer fixes this. We now use Jason encode with ordered keys option.

Leaving a comment in case someone else runs into this in the future.

@ananthakumaran
Copy link
Contributor

Thanks for reporting. If your fix is generic, we can do the same in ExqScheduler itself. I will look into this weekend

@barttenbrinke
Copy link

Ran into this too, this might be a good thing :)

@mkarnebeek
Copy link

Exq Scheduler pushes jobs into the queue at intervals specified by the schedule configuration. It is designed to run on more than one machine for redundancy without causing duplicate jobs to be scheduled.

One of the first lines from the readme and the reason for using this library.

I'd say this is the main feature of this library and needs to be addressed. Have you had a chance to take a look at this?

@ananthakumaran
Copy link
Contributor

ananthakumaran commented Nov 20, 2024

Using a custom serializer fixes this. We now use Jason encode with ordered keys option.

@marcowindt I couldn't find any option named ordered_keys or similar, did you use Jason.OrderedObject?

@mkarnebeek I have the fix ready #44, if you could test it, it would be great.

@mkarnebeek
Copy link

Thank you for the very fast fix! I will test this today and let you know

@marcowindt
Copy link
Author

@ananthakumaran Yes, we use it as follows:

input
|> Jason.decode!(objects: :ordered_objects)

@barttenbrinke
Copy link

Nice!

@mkarnebeek
Copy link

Deployed to various stages and ended on production yesterday. This morning it looked good. So ✅! Thank you very much for the fast response!

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

Successfully merging a pull request may close this issue.

4 participants