Skip to content

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ninsmiracle
Copy link
Contributor

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 sets MANUAL_COMPACT_PERIODIC_TRIGGER_TIME_KEY for the first time in app_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 initial MANUAL_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
  • Unit test
  • Cluster test

@github-actions github-actions bot added the cpp label Jul 11, 2023
std::atomic<int> _max_concurrent_running_count;
std::atomic<uint64_t> _manual_compact_first_day_s;
Copy link
Member

@acelyc111 acelyc111 Aug 3, 2023

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 &&
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants