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

fix(storage): refactor emergency picker #15954

Merged
merged 15 commits into from
Apr 15, 2024
Merged

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Mar 27, 2024

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

#15496 (comment)

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added test labels as necessary. See details.
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)
  • My PR contains critical fixes that are necessary to be merged into the latest release. (Please check out the details)

Documentation

  • My PR needs documentation updates. (Please use the Release note section below to summarize the impact on users)

Release note

If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.

// 1. pull task from hummock_manager
// 2. send task to compactor
async fn pull_task_handler(hummock_manager: Arc<HummockManager>, pull_task_count: u32, group: u64, selector: &mut Box<dyn CompactionSelector>, task_type: TaskType, compactor: Arc<Compactor>) -> usize {
let mut pick_task_count = 0;
Copy link
Contributor

@MrCroxx MrCroxx Mar 29, 2024

Choose a reason for hiding this comment

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

Is it okay to recount pick_task_count for each pull? If there are enough tasks, the count of picked tasks will be 2 times of the target.


let pick_task_count = pull_task_handler(hummock_manager.clone(), pull_task_count, group, selector, task_type, compactor.clone()).await;
// if the pick_task_count is less than `EXPECTED_PULL_TASK_RATIO`, try to pull the left tasks from emergency selector when write-stop
const EXPECTED_PULL_TASK_RATIO: f32 = 0.75;
Copy link
Contributor

@MrCroxx MrCroxx Mar 29, 2024

Choose a reason for hiding this comment

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

Same with the comment above. Will it be better to pass the pick_task_count: &mut usize for limitation across pulls instead of limiting each pull to 75%?

Copy link
Contributor

@MrCroxx MrCroxx left a comment

Choose a reason for hiding this comment

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

LGTM

cc @Little-Wallace

@hzxa21 hzxa21 changed the title refactor(storage): refactor emergency picker fix(storage): refactor emergency picker Apr 3, 2024
@Li0k Li0k force-pushed the li0k/storage_refactor_emergency branch 2 times, most recently from 1d6ef21 to 59b99bf Compare April 8, 2024 07:55
@Li0k Li0k force-pushed the li0k/storage_refactor_emergency branch from 58a5c28 to 0f7dc65 Compare April 8, 2024 12:55
src/meta/src/hummock/manager/mod.rs Show resolved Hide resolved
Comment on lines 223 to 226
let mut generated_task_count = 0;
let mut existed_groups = groups.clone();
let mut no_task_groups: HashSet<CompactionGroupId> = HashSet::default();
let mut failed_tasks = vec![];
Copy link
Collaborator

Choose a reason for hiding this comment

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

nits: there are two patterns to mutate these variables

  • existed_groups and no_task_groups are mutabled inside handle_pick_tasks by passing &mut
  • generated_task_count and failed_tasks are mutabled outside of handle_pick_tasks by using the returned result.

Can we converge them to one pattern?

{
Some(config) => config.compaction_config.enable_emergency_picker,
None => {
unreachable!("compaction-group {} not exist", cg_id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it really unreachable? Will compaction group be destroyed if the table in the cg is dropped?

Copy link
Collaborator

@hzxa21 hzxa21 left a comment

Choose a reason for hiding this comment

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

Rest LGTM!

src/meta/src/hummock/manager/versioning.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Little-Wallace Little-Wallace left a comment

Choose a reason for hiding this comment

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

rest LGTM

@Li0k Li0k enabled auto-merge April 15, 2024 07:24
@Li0k Li0k added this pull request to the merge queue Apr 15, 2024
Merged via the queue into main with commit 72c8bec Apr 15, 2024
28 of 29 checks passed
@Li0k Li0k deleted the li0k/storage_refactor_emergency branch April 15, 2024 08:19
Li0k added a commit that referenced this pull request Apr 19, 2024
github-merge-queue bot pushed a commit that referenced this pull request Apr 22, 2024
Co-authored-by: Li0k <yuli@singularity-data.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants