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

Improvements for Job#retry #318

Merged
merged 4 commits into from
Jul 12, 2016
Merged

Conversation

xdc0
Copy link
Contributor

@xdc0 xdc0 commented Jul 6, 2016

This PR makes some improvements on the current Job#retry implementation:

  • The retry operation is now implemented through a script, to follow suit with the other operations
  • The retry operation does several checks while attempting to retry a job:
    • It checks if the job exists, so that a non-existent job can be accidentally retried
    • It checks if the job is currently locked, to avoid possible corruption on job data
    • It checks if the job is actually failed, so it avoids retrying job that are in any other state that is not failed.

@xdc0
Copy link
Contributor Author

xdc0 commented Jul 6, 2016

This is similar to: #232 except that it has more extensive failure handling, more job integrity checks, is in scripts.js and has tests

attempts++;
jobDone(new Error('failed'));
} else {
jobDone();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity here we could just throw and error or not returning anything, and skip the jobDone callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks! will amend

'else',
' return 0',
'end'
].join('\n');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of this nested code I would propose something like this:

if ((redis.call("EXISTS", KEYS[1]) ~= 1) then
  return 0
end
if ((redis.call("EXISTS", KEYS[2])  ~= 0) then
  return -1
end
.
.
.
return 1;

@manast manast merged commit f5d0563 into OptimalBits:master Jul 12, 2016
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 this pull request may close these issues.

3 participants