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(meta): unify code for different kinds of source change #19991

Merged

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Jan 2, 2025

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

What's changed and what's your intention?

Previously, we have multiple code paths for different kinds of source changes: e.g., unregister_source, drop_source_fragments, and apply_source_change. Actually they have some overlap, and some missing cleanup tasks forgotten to do.

Since what they did is really similar: update states after some operations, in this PR, I try to merge them in to one func call, and dispatch by enum variant. This makes it easier for caller to choose what to call, and can help maintain consistency in the cleanup impl.

Prepare for #18416

Checklist

  • I have written necessary rustdoc comments.
  • I have added necessary unit tests and integration tests.
  • I have added test labels as necessary.
  • I have added fuzzing tests or opened an issue to track them.
  • My PR contains breaking changes.
  • My PR changes performance-critical code, so I will run (micro) benchmarks and present the results.
  • My PR contains critical fixes that are necessary to be merged into the latest release.

Documentation

  • My PR needs documentation updates.
Release note

Copy link
Member Author

xxchan commented Jan 2, 2025

@xxchan xxchan marked this pull request as ready for review January 2, 2025 07:47
@xxchan xxchan force-pushed the xxchan/collective-gazelle branch from dc46eac to 340d80c Compare January 2, 2025 07:57
@xxchan xxchan force-pushed the 01-02-refactor_unify_code_for_different_kinds_of_source_change branch 3 times, most recently from 478f935 to ff48e40 Compare January 2, 2025 09:13
@xxchan xxchan changed the title refactor: unify code for different kinds of source change refactor(meta): unify code for different kinds of source change Jan 2, 2025
@xxchan xxchan requested review from BugenZhao, shanicky and stdrc January 2, 2025 09:48
Base automatically changed from xxchan/collective-gazelle to main January 3, 2025 02:38
@@ -166,7 +167,7 @@ impl CommandContext {
.await?;
barrier_manager_context
.source_manager
.apply_source_change(None, None, Some(split_assignment.clone()), None, None)
Copy link
Member

Choose a reason for hiding this comment

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

Wow, five Option seems really unreadable.

.append(&mut fragment_ids);
/// Updates states after all kinds of source change.
pub fn apply_source_change(&mut self, source_change: SourceChange) {
let mut added_source_fragments = Default::default();
Copy link
Member

Choose a reason for hiding this comment

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

Such boilerplate 😄

@xxchan xxchan force-pushed the 01-02-refactor_unify_code_for_different_kinds_of_source_change branch from ff48e40 to a2a3cb3 Compare January 3, 2025 03:02
@xxchan xxchan enabled auto-merge January 3, 2025 03:04
@xxchan xxchan added this pull request to the merge queue Jan 3, 2025
Merged via the queue into main with commit 194f8bb Jan 3, 2025
32 of 33 checks passed
@xxchan xxchan deleted the 01-02-refactor_unify_code_for_different_kinds_of_source_change branch January 3, 2025 03:42
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.

2 participants