-
Notifications
You must be signed in to change notification settings - Fork 609
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): reorganize global barrier manager field #18920
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 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. |
96609a6
to
6bb2755
Compare
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.
Generally LGTM. Thanks for the refactoring!
@@ -762,17 +817,33 @@ impl GlobalBarrierManager { | |||
_ => {} | |||
} | |||
} | |||
complete_result = self | |||
.completing_task | |||
.next_completed_barrier( |
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.
Any specific reason why we change to prefer next_completed_barrier
over next_complete_barrier_response
in this PR.
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.
Actually both the two methods are still there. The name of next_complete_barrier_response
may be confusing, because it actually means the collect barrier response. The reason for the naming previously is because the name of the protobuf message of the response type is CompleteBarrierResponse
. I have changed the name to next_collect_barrier_response
.
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.
Sorry for the confusion. What I was asking here is not about the naming, but about the priority of the select arm. Prior to this PR, we poll next_completed_barrier
first and then next_complete_barrier_response
but after this PR we switch the order.
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.
In this PR, the next_completed_barrier
takes the mutable reference of control_stream_manager
to generate the future (though the mutable reference is used, the generated future won't capture the mutable reference).
In the original poll order, the mutable reference of control_stream_manager
will have been captured by the future generated from next_complete_barrier_response
, and cannot be used when generating the future of next_completed_barrier
.
if !finished_jobs.is_empty() | ||
&& let Some((_, control_stream_manager)) = &mut context | ||
{ | ||
control_stream_manager.remove_partial_graph( |
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.
Are we planning to support resumable MV creation after meta failover? We move remove_partial_graph
from after commit_epoch
to before commit_epoch
, which means that we won't be able to re-send the "finished" epoch to creating MV after recovery. Will this affect failover implementation in the future?
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.
The remove_partial_graph
is just a message to clean up the in memory state of the finished partial graph, and will not affect any committed state. After failover, the partial graph can be resumed whenever there are some recovered creating streaming jobs.
hummock_version_stats: HummockVersionStats, | ||
|
||
create_mview_tracker: CreateMviewProgressTracker, | ||
|
||
context: GlobalBarrierManagerContext, | ||
context: GlobalBarrierWorkerContext, | ||
} | ||
|
||
impl CheckpointControl { |
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.
I think mod.rs
is becoming a bit too large, which also affects reability. impl CheckpointControl
, impl GlobalBarrierWorker
and impl GlobalBarrierManager
are somehow mixed together. I can imagine for people who are not familiar with logics here can easily get lost. Now we have clearer cut of responsibility for CheckpointControl
and GlobalBarrierWorker
, I am thinking maybe we should have separate files for them and maybe for other structs as well. We can do it in a separate PR or along with the future refactoring PR.
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.
Will reorganize the code after implementing the database isolation feature, because there are several pending PR, and if we reorganize the code in this PR, the pending PRs will have many conflicts.
IIUC GlobalBarrierManager will be the external interface used by other services, e.g. |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
This PR includes some general refactors on the global barrier manager.
First, currently we have
GlobalBarrierManager
andGlobalBarrierManagerContext
.GlobalBarrierManager
is actually a owned worker that works in a loop to handle different async barrier event, andGlobalBarrierManagerContext
holds some shared structs and is used by both theGlobalBarrierManager
worker and other external usages (e.g. DdlController and etc). In this PR, theGlobalBarrierManager
worker is renamed toGlobalBarrierWorker
, andGlobalBarrierManagerContext
is renamed toGlobalBarrierWorkerContext
, and will be used by onlyGlobalBarrierWorker
. The external usages will only use a newGlobalBarrierManager
, which contains only the fields used by the external usages. With this refactor, only theGlobalBarrierManager
has thepub
visibility, and theGlobalBarrierWorker
and theGlobalBarrierWorkerContext
will only be visible within the crate.Second, in the code of barrier manager, the tuple
(prev_epoch, curr_epoch, barrier_kind)
appears together in many codes. In this PR, we extract them to a new structBarrierInfo
that holds the 3 fields, and some related code can be less verbose.Third, the
BarrierWorkerState
will be moved fromGlobalBarrierWorker
toCheckpointControl
, and the logic ofhandle_new_barrier
inGlobalBarrierWorker
is narrowed down to only withinCheckpointControl
, so that it becomes a method ofCheckpointControl
only. Besides, previously inGlobalBarrierWorker
, we have a separate fieldpending_non_checkpoint_barriers
, which tracks the inflight non-checkpoint barrier before the next checkpoint barrier. In this PR, the field is moved toBarrierWorkerState
, and we introduce a methodnext_barrier_info
to generate aBarrierInfo
of the next barrier in a single method call. Inhandle_new_barrier
, theBarrierWorkerState
becomes immutable afterapply_command
.Fourth, the
CompletingTask
is moved out ofCheckpointControl
toGlobalBarrierWorker
, which decouples the logicalCheckpointControl
from the physical join handle that callscommit_epoch
. In the future PR that supports database isolation, we will have aCheckpointControl
per database, but still a single globalCompletingTask
.Checklist
./risedev check
(or alias,./risedev c
)Documentation
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.