-
Notifications
You must be signed in to change notification settings - Fork 433
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
fix(job-scheduler): validate if next delayed job exists #3015
Open
roggervalf
wants to merge
10
commits into
master
Choose a base branch
from
fix-scheduler-no-add-existing-job
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
41f1659
fix(job-scheduler): validate if next delayed job exists
roggervalf 5961c09
chore: remove comment
roggervalf a7f93d9
chore: remove extra and operator
roggervalf 9400c4a
refactor: change order of validation of existing next delayed job
roggervalf 7e72eee
test: fix test case for dragonfly
roggervalf 00aa7d1
chore: extract storeJobScheduler include
roggervalf 4eb7930
refactor(job-scheduler): increase iterationCount only when next delay…
roggervalf 912b944
test: fix test case
roggervalf 5e9015a
test: try to fix flaky test
roggervalf 0b099b9
chore: fix merge conflicts
roggervalf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--[[ | ||
Function to store a job scheduler | ||
]] | ||
local function storeJobScheduler(schedulerId, schedulerKey, repeatKey, nextMillis, opts, templateData, templateOpts) | ||
rcall("ZADD", repeatKey, nextMillis, schedulerId) | ||
|
||
local optionalValues = {} | ||
if opts['tz'] then | ||
table.insert(optionalValues, "tz") | ||
table.insert(optionalValues, opts['tz']) | ||
end | ||
|
||
if opts['pattern'] then | ||
table.insert(optionalValues, "pattern") | ||
table.insert(optionalValues, opts['pattern']) | ||
end | ||
|
||
if opts['endDate'] then | ||
table.insert(optionalValues, "endDate") | ||
table.insert(optionalValues, opts['endDate']) | ||
end | ||
|
||
if opts['every'] then | ||
table.insert(optionalValues, "every") | ||
table.insert(optionalValues, opts['every']) | ||
end | ||
|
||
local jsonTemplateOpts = cjson.encode(templateOpts) | ||
if jsonTemplateOpts and jsonTemplateOpts ~= '{}' then | ||
table.insert(optionalValues, "opts") | ||
table.insert(optionalValues, jsonTemplateOpts) | ||
end | ||
|
||
if templateData and templateData ~= '{}' then | ||
table.insert(optionalValues, "data") | ||
table.insert(optionalValues, templateData) | ||
end | ||
|
||
rcall("HMSET", schedulerKey, "name", opts['name'], "ic", 0, | ||
unpack(optionalValues)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of removing the job here and then adding a new one, couldn't we just set a flag here and if true not add the job again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem is that if the delayed is not regenerated with new repeat opts, next delayed job will be scheduled with old repeat options. This is happening in that way because we use opts from current delayed job to schedule the next one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, can you write a comment then to explain why it is needed so we not need to remember it next time? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I'll add a description about it