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

refactor(storage): refactor compaction event loop #14631

Merged
merged 19 commits into from
Feb 4, 2024

Conversation

Li0k
Copy link
Contributor

@Li0k Li0k commented Jan 17, 2024

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

What's changed and what's your intention?

#13879

Introduce a dedicated loop for CPU-bound / IO-bound events to avoid slow events from occupying the event loop thread for a long time, causing the basic event loop to starve.

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.

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.

What does this PR propose for ?

@Li0k
Copy link
Contributor Author

Li0k commented Jan 18, 2024

What does this PR propose for ?

#13879 (comment)

@Li0k Li0k marked this pull request as ready for review January 22, 2024 05:28
@Li0k Li0k requested review from hzxa21, zwang28 and wenym1 January 22, 2024 05:28
let mut event_loop_iteration_now = Instant::now();
loop {
let shutdown_rx_shared = shutdown_rx_shared.clone();
async fn compact_task_event_handler(
Copy link
Contributor

Choose a reason for hiding this comment

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

How about define this method outside

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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.

LGTM

Copy link
Contributor

@zwang28 zwang28 left a comment

Choose a reason for hiding this comment

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

LGTM

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/mod.rs Show resolved Hide resolved
Comment on lines 2755 to -2756
let mut compactor_alive = true;
let (context_id, compactor_stream_req) = result;

let (context_id, compactor_stream_req): (_, (std::option::Option<std::result::Result<SubscribeCompactionEventRequest, _>>, _)) = result;
let (event, create_at, stream) = match compactor_stream_req {
(Some(Ok(req)), stream) => {
(req.event.unwrap(), req.create_at, stream)
}

(Some(Err(err)), _stream) => {
tracing::warn!(error = %err.as_report(), "compactor {} leaving the cluster with err", context_id);
hummock_manager.compactor_manager
.remove_compactor(context_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why remove this?

Comment on lines 2762 to -2763

(Some(Err(err)), _stream) => {
tracing::warn!(error = %err.as_report(), "compactor {} leaving the cluster with err", context_id);
hummock_manager.compactor_manager
.remove_compactor(context_id);
tracing::warn!(error = %err.as_report(), "compactor stream {} poll with err, recv stream may be destroyed", context_id);
continue
}

_ => {
tracing::warn!("compactor {} leaving the cluster", context_id);
hummock_manager.compactor_manager
.remove_compactor(context_id);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove_compactor will remove the tx via context_id. Therefore, we only remove tx when send fails and rx when recv fails.

In short: avoid having multiple branches operating removing tx

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

gitguardian bot commented Feb 2, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9425213 Triggered Generic Password dbc5c52 ci/scripts/regress-test.sh View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

@Li0k Li0k enabled auto-merge February 2, 2024 10:09
@Li0k Li0k added this pull request to the merge queue Feb 4, 2024
Merged via the queue into main with commit 9e90eeb Feb 4, 2024
26 of 27 checks passed
@Li0k Li0k deleted the li0k/storage_compact_event_loop branch February 4, 2024 04:53
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.

4 participants