-
Notifications
You must be signed in to change notification settings - Fork 313
fix: manual compact unexpected start #1565
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
base: master
Are you sure you want to change the base?
fix: manual compact unexpected start #1565
Conversation
std::atomic<int> _max_concurrent_running_count; | ||
std::atomic<uint64_t> _manual_compact_first_day_s; |
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.
Could you please add some comments for the newly added variable?
The logic is too complex if adding these variables, if the current "periodic", "max_concurrent_running" features are not well implemented, I don't mind you to rewrite or even remove them.
for (auto t : trigger_time) { | ||
auto t_ms = t * 1000; | ||
|
||
if (_manual_compact_first_day_s.load() == cur_day_midnight && t_ms < now && |
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.
It's allowed to set multiple periodic compact tasks on a table, for example there are 2 tasks set to be executed at 02:00 and 16:00, now real world time is 15:00, will the second task (16:00 one) to be executed normally?
What problem does this PR solve?
#1564
What is changed and how does it work?
My modifications mainly focus on
pegasus_manual_compact_service::check_periodic_compact
. When the user setsMANUAL_COMPACT_PERIODIC_TRIGGER_TIME_KEY
for the first time inapp_envs
, the midnight of the date on which the time is set is recorded.If the user sets the trigger time to 02:00 and the current time is 15:00, they want to perform manual_compact again at 02:00 the next day.
_manual_compact_first_day_s.load() == cur_day_midnight && t_ms < now
effectively restricts manual_compact on the same day for the user.However, if the user sets the trigger time to 16:00 and the current time is still 15:00, it is obvious that the user wants to do manual_compact at 16:00 on the same day. The
_time_natural_increase
member variable resolves this situation by indicating that the time has naturally progressed under the current logic, rather than comparing it with the initialMANUAL_COMPACT_PERIODIC_TRIGGER_TIME_KEY
setting.Lastly, if the user deletes the
MANUAL_COMPACT_PERIODIC_TRIGGER_TIME_KEY
parameter and then sets it again, it will be treated as the first-time setting.Checklist
Tests