Count only the controller's own consumers in the deaf look, not the check workers a builder holds (issue 1063)

This commit is contained in:
2026-10-20 23:14:45 +00:00
parent f4584e6fa2
commit 233db89f29
3 changed files with 116 additions and 9 deletions
+21 -7
View File
@@ -621,21 +621,35 @@ func p90(took []time.Duration) time.Duration {
return sorted[int(0.9*float64(len(sorted)-1))]
}
// loopConsumers are the controller's own consumers: the loop never takes from the build seat's check workers (issue 1063).
func loopConsumers() []broker.Consumer { return broker.ControllerConsumers() }
// gatherLoop is when the event loop last took a message and what its consumers hold.
func (w *watchdogs) gatherLoop() (loopFacts, error) {
f := loopFacts{took: link.Loop.Last()}
if w.js == nil {
return f, errors.New("this controller is not on the bus")
return loopFacts{took: link.Loop.Last()}, errors.New("this controller is not on the bus")
}
var where []string
for _, c := range broker.MeshConsumers() {
return readLoop(link.Loop.Last(), loopConsumers(), func(c broker.Consumer) (uint64, error) {
info, err := w.js.Context().ConsumerInfo(c.Stream, c.Name)
if err != nil {
return 0, err
}
return info.NumPending + uint64(info.NumAckPending), nil
})
}
// readLoop sums what the given consumers hold, as held reads each.
func readLoop(took time.Time, consumers []broker.Consumer, held func(broker.Consumer) (uint64, error)) (loopFacts, error) {
f := loopFacts{took: took}
var where []string
for _, c := range consumers {
n, err := held(c)
if err != nil {
return f, fmt.Errorf("the controller's consumer on %s cannot be read: %w", c.Stream, err)
}
if held := info.NumPending + uint64(info.NumAckPending); held > 0 {
f.pending += held
where = append(where, fmt.Sprintf("%d on %s", held, c.Stream))
if n > 0 {
f.pending += n
where = append(where, fmt.Sprintf("%d on %s", n, c.Stream))
}
}
f.where = fmt.Sprint(where)