Skip to content

Commit 32e2273

Browse files
committed
maintainer,heartbeatpb: clarify drain comments
1 parent 5cb3d57 commit 32e2273

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

heartbeatpb/heartbeat.pb.go

Lines changed: 11 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

heartbeatpb/heartbeat.proto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,17 @@ message MaintainerHeartbeat {
141141

142142
// DrainProgress is maintainer-observed progress for dispatcher drain on one target.
143143
message DrainProgress {
144+
// target_node_id is the node currently being evacuated for this changefeed.
145+
// It matches the active dispatcher drain target seen by this maintainer.
144146
string target_node_id = 1;
147+
// target_epoch is the epoch attached to target_node_id.
148+
// Reviewers should read (target_node_id, target_epoch) as one monotonic target snapshot.
145149
uint64 target_epoch = 2;
150+
// target_dispatcher_count is the current number of this changefeed's
151+
// dispatchers still hosted on target_node_id in the maintainer snapshot.
146152
uint32 target_dispatcher_count = 3;
153+
// target_inflight_drain_move_count is the number of unfinished move
154+
// operators already evacuating dispatchers away from target_node_id.
147155
uint32 target_inflight_drain_move_count = 4;
148156
}
149157

maintainer/maintainer_manager_maintainers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ import (
3131
"go.uber.org/zap"
3232
)
3333

34+
// managerMaintainerSet owns the changefeed-scoped part of a maintainer manager.
35+
// It tracks the local changefeedID -> maintainer registry, creates and removes
36+
// maintainers, routes maintainer-bound messages, and aggregates maintainer
37+
// heartbeats back to coordinator.
38+
//
39+
// In contrast, managerNodeState owns node-scoped state shared by the whole
40+
// capture, such as liveness, node epoch, and the latest manager-level drain
41+
// target. The Manager combines both layers: managerNodeState is the single
42+
// node-wide source of truth, while managerMaintainerSet fans that node-scoped
43+
// state out to individual maintainers and manages their per-changefeed
44+
// lifecycles.
3445
type managerMaintainerSet struct {
3546
// conf is shared scheduler configuration for newly created maintainers.
3647
conf *config.SchedulerConfig

maintainer/maintainer_manager_node.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ type managerNodeState struct {
3838
// must match it so stale requests from a previous process instance are ignored.
3939
nodeEpoch uint64
4040

41-
// dispatcherDrainTarget caches the latest coordinator-issued dispatcher drain
42-
// target at manager scope so this node can acknowledge activation and clear
43-
// even when it temporarily hosts no maintainers.
41+
// dispatcherDrainTarget stores the latest drain target for dispatcher
42+
// evacuation already applied on this capture. Here "dispatcher" explains
43+
// what is being drained: the dispatcher tasks currently hosted on the target
44+
// node, not the maintainer itself and not the node-liveness state. It is
45+
// capture-wide state, not per-changefeed state. Keeping it here lets the
46+
// manager acknowledge "target set" and "target cleared" in node heartbeat
47+
// even when this capture currently hosts no maintainers.
4448
dispatcherDrainTarget struct {
4549
sync.RWMutex
4650
target node.ID

maintainer/scheduler/drain_common.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,25 @@ const balanceDrainCooldown = 120 * time.Second
2929
// changefeed. All schedulers read it through snapshots so a single tick sees a
3030
// consistent view of the maintainer host and the active drain target.
3131
type DrainState struct {
32+
// mu protects the full drain-state snapshot so schedulers can read a
33+
// consistent self/target view within one tick.
3234
mu sync.RWMutex
3335

34-
selfNodeID node.ID
36+
// selfNodeID is the node currently hosting this changefeed maintainer.
37+
selfNodeID node.ID
38+
// targetNodeID is the node currently being evacuated for this changefeed.
3539
targetNodeID node.ID
36-
targetEpoch uint64
40+
// targetEpoch is the monotonic epoch paired with targetNodeID.
41+
targetEpoch uint64
3742
}
3843

3944
type drainStateSnapshot struct {
40-
selfNodeID node.ID
45+
// selfNodeID is the snapshot copy of the maintainer host node.
46+
selfNodeID node.ID
47+
// targetNodeID is the snapshot copy of the active drain target node.
4148
targetNodeID node.ID
42-
targetEpoch uint64
49+
// targetEpoch is the snapshot copy of the active drain target epoch.
50+
targetEpoch uint64
4351
}
4452

4553
// NewDrainState creates an empty drain state with no active drain target.

0 commit comments

Comments
 (0)