-
Notifications
You must be signed in to change notification settings - Fork 430
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 Issue #388: Celery Beat scheduled tasks may be executed repeatedly #660
Conversation
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.
you can try to add new tests for this. also if yyou can fix the failing test in this or another PR, it will be really helpful
你从代码逻辑上来看这样修改是对的吗? Is it right to modify it in this way from the logical point of view of code? If there is no problem, I will consider adding its test cases. |
I think you can proceed with tests |
Okay, it might take a while. |
|
||
# Check | ||
assert e1_pre_sync_last_run_at == e1_post_sync_last_run_at | ||
|
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.
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 test case has been added, you can review it, thank you. |
Describe
Fix the problem that Celery Beat scheduled tasks may be executed repeatedly
Problem
Describe
If
self.schedule
is called, it may cause the data in the database to be retrieved before theself.save()
method, instead of the temporarily setlast_run_at data
If
self.schedule
is called hereThen it may cause the
last_run_at
ofself.schedule[name]
calling save to be the old data retrieved from the databaseInstead of
last_run_at
temporarily set after task execution (set in__next__()
method)After the
max_interval
interval, the next task detection cycle will still execute the task againDemo
Task information:
The first execution of the task: 18:03 (set
last_run_at
= 18:03 when executing, and it is in memory at this time)beat: Waking up 60s...
The second execution of the task: 18:04 (because the
last_run_at
obtained is 18:00,entry.is_due()
==True
)Test
There are currently no test cases.
Effect
After modifying the code, the problem of repeated execution no longer appeared in our project JumpServer.