risingwave
risingwave copied to clipboard
refactor(meta): reorganize global barrier manager field
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
and GlobalBarrierManagerContext
. GlobalBarrierManager
is actually a owned worker that works in a loop to handle different async barrier event, and GlobalBarrierManagerContext
holds some shared structs and is used by both the GlobalBarrierManager
worker and other external usages (e.g. DdlController and etc). In this PR, the GlobalBarrierManager
worker is renamed to GlobalBarrierWorker
, and GlobalBarrierManagerContext
is renamed to GlobalBarrierWorkerContext
, and will be used by only GlobalBarrierWorker
. The external usages will only use a new GlobalBarrierManager
, which contains only the fields used by the external usages. With this refactor, only the GlobalBarrierManager
has the pub
visibility, and the GlobalBarrierWorker
and the GlobalBarrierWorkerContext
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 struct BarrierInfo
that holds the 3 fields, and some related code can be less verbose.
Third, the BarrierWorkerState
will be moved from GlobalBarrierWorker
to CheckpointControl
, and the logic of handle_new_barrier
in GlobalBarrierWorker
is narrowed down to only within CheckpointControl
, so that it becomes a method of CheckpointControl
only. Besides, previously in GlobalBarrierWorker
, we have a separate field pending_non_checkpoint_barriers
, which tracks the inflight non-checkpoint barrier before the next checkpoint barrier. In this PR, the field is moved to BarrierWorkerState
, and we introduce a method next_barrier_info
to generate a BarrierInfo
of the next barrier in a single method call. In handle_new_barrier
, the BarrierWorkerState
becomes immutable after apply_command
.
Fourth, the CompletingTask
is moved out of CheckpointControl
to GlobalBarrierWorker
, which decouples the logical CheckpointControl
from the physical join handle that calls commit_epoch
. In the future PR that supports database isolation, we will have a CheckpointControl
per database, but still a single global CompletingTask
.
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 #7934).
- [ ] My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
- [x] 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.