An idle build machine's empty fetch is asked again, not read as the end (hq ADR 0190) #234

Merged
mesh-admin merged 1 commits from fix/an-empty-fetch-is-not-the-end into main 2026-10-03 09:41:53 +00:00
Showing only changes of commit 59166b1031 - Show all commits
+8 -2
View File
@@ -193,9 +193,15 @@ func (m *natsMachine) Take(ctx context.Context, do func(context.Context, Build))
// machine with nothing to build, and is asked again. // machine with nothing to build, and is asked again.
fetched, err := sub.Fetch(1, nats.Context(ctx)) fetched, err := sub.Fetch(1, nats.Context(ctx))
switch { switch {
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded): case ctx.Err() != nil:
// Ours ended: the machine is being stopped.
return nil return nil
case errors.Is(err, nats.ErrTimeout): case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded), errors.Is(err, nats.ErrTimeout):
// **An empty queue, not the end.** A fetch on a context without a deadline waits the
// client's own while and then says the deadline passed — the client's, not ours. Read
// as "stop", every idle build machine exited clean every half minute and was started
// again by its supervisor, which looked like a crash loop with nothing in the log to
// say why (2026-10-03, the first build agents). Asked again.
continue continue
case err != nil: case err != nil:
if sub.IsValid() { if sub.IsValid() {