Drop the module leader recompute event
The queue event did two things: set the routing-changed flag, which the lifecycle event of the same change already sets, and deliver the leader-change info log. It cost an extra raft INSERT per connect/disconnect, two GetForLeaderElection reads per lifecycle event used for nothing else, a payload kind, a compaction key and a subscription-service method that only logged. The leader is now logged where it is published: the address-list emission logs the leader it just sent, and the routing rebuild logs one summary line with the leaders it published. Modules without election stay silent, as before. A future self-election needs a recompute trigger that also re-broadcasts the address list; that event will be added when the requirement exists, not carried as a no-op.
This commit is contained in:
1 parent
a8a475435c
commit
439e6f5ebf
9 files changed
+159
-553
No files matched your search
@@ -19,13 +19,6 @@ func NewEvent(payload EventPayload) Event {
|
||||
}
|
||||
}
|
||||
|
||||
// Module leader recompute reasons. They tell the log which change of the cluster put the event in the queue,
|
||||
// and only that: the leader itself is taken from the module instances every time it is needed.
|
||||
const (
|
||||
ModuleLeaderReasonReady = "ready"
|
||||
ModuleLeaderReasonDisconnect = "disconnect"
|
||||
)
|
||||
|
||||
func (e Event) Key() string {
|
||||
switch {
|
||||
case e.Payload.Value.ConfigUpdated != nil:
|
||||
@@ -34,10 +27,6 @@ func (e Event) Key() string {
|
||||
return fmt.Sprintf("module_lifecycle_%s", e.Payload.Value.ModuleReady.ModuleId)
|
||||
case e.Payload.Value.ModuleDisconnected != nil:
|
||||
return fmt.Sprintf("module_lifecycle_%s", e.Payload.Value.ModuleDisconnected.ModuleId)
|
||||
case e.Payload.Value.ModuleLeaderRecompute != nil:
|
||||
// The leader recompute keeps its own key: the compactor collapses ready and disconnected into one
|
||||
// lifecycle event per module, and the recompute must not be swallowed by that collapse.
|
||||
return fmt.Sprintf("module_leader_%s", e.Payload.Value.ModuleLeaderRecompute.ModuleId)
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
@@ -48,8 +37,6 @@ type EventPayload struct {
|
||||
ConfigUpdated *PayloadConfigUpdated `json:",omitempty"`
|
||||
ModuleReady *PayloadModuleReady `json:",omitempty"`
|
||||
ModuleDisconnected *PayloadModuleDisconnected `json:",omitempty"`
|
||||
// ModuleLeaderRecompute is internal: no module receives it as a WebSocket event.
|
||||
ModuleLeaderRecompute *PayloadModuleLeaderRecompute `json:",omitempty"`
|
||||
}
|
||||
|
||||
type PayloadConfigUpdated struct {
|
||||
@@ -63,22 +50,3 @@ type PayloadModuleReady struct {
|
||||
type PayloadModuleDisconnected struct {
|
||||
ModuleId string
|
||||
}
|
||||
|
||||
// PayloadModuleLeaderRecompute asks the config service to look at the module leader again.
|
||||
//
|
||||
// PreviousLeader is the address the leader had before the change, and Leader is the address derived from the
|
||||
// module instances after it, empty when the module has no leader left. Both are assembled where the change
|
||||
// happens, together with the events of that change, so the event worker reads nothing from the database: an
|
||||
// extra read there races with the events of the same cluster and slows the whole queue down. The leader
|
||||
// address the modules see is still elected by the read path when it serves a request.
|
||||
//
|
||||
// nolint:tagliatelle
|
||||
type PayloadModuleLeaderRecompute struct {
|
||||
ModuleId string
|
||||
ModuleName string
|
||||
Reason string
|
||||
// PreviousLeader is empty when the module had no leader.
|
||||
PreviousLeader string
|
||||
// Leader is empty when the module has no leader after the change.
|
||||
Leader string
|
||||
}
|
||||
Reference in new issue
Block a user