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

Lock expiry can potentially cause job to run twice #69

Open
Roam-Cooper opened this issue Dec 2, 2016 · 1 comment
Open

Lock expiry can potentially cause job to run twice #69

Roam-Cooper opened this issue Dec 2, 2016 · 1 comment

Comments

@Roam-Cooper
Copy link
Contributor

Roam-Cooper commented Dec 2, 2016

In kue-scheduler 0.6.3 (and higher versions as far as I know), it seems as though the test that the key expiry listener used to determine whether it should run "_onJobKeyExpiry" for the expired key is also satisfied by lock key expiries.

The test is:
queue._jobExpiryKeyValidator = new RegExp('^' + queue.options.prefix + ':scheduler:');

Which a lock key of q:scheduler:locks:unique_task_name would meet.

@Roam-Cooper
Copy link
Contributor Author

Roam-Cooper commented Dec 7, 2016

I am working on a pull request to resolve this issue, I just have to look into our deployment a bit further as the root of the issue is a lock not being unlocked, and the expiry of the lock passes as a scheduler expiry because the regex allows it.

Seems in our deployment it was causing the task to run twice, because when the lock key expires and passes for a scheduler expiry, it gets a lock on the expired lock key, and that lock will expire after 1000ms and also pass for a scheduler expiry. After all is said and done the "scheduler key" (really the lock's key) is reset with the tasks interval time and the process repeats.

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