From 30ccad4edcde50ef626b1a386ff48741ca66b1cb Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 20 Nov 2026 21:15:30 +0100 Subject: [PATCH] Assigner tests: hold putInto's writes one at a time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The composition step starts its machines' runs side by side, and each may raise assignment-unlisted into the test's map: unguarded, the unit suite crashed now and then with concurrent map writes. Only the test raced; the running module writes the bus's findings state. Builds: design 47 H ยง774 --- .../cmd/mesh-delivery-assigner/main_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go index cd1af9b7..296cea00 100644 --- a/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go +++ b/modules/mesh-delivery-assigner/cmd/mesh-delivery-assigner/main_test.go @@ -19,6 +19,7 @@ import ( "runtime" "slices" "strings" + "sync" "testing" "time" @@ -203,11 +204,17 @@ func (w *watchKV) Keys(context.Context, ...jetstream.WatchOpt) ([]string, error) return nil, jetstream.ErrNoKeysFound } +// putIntoMu holds putInto's writes one at a time: the composition step starts its machines' runs side by side, and each may +// raise a finding into the same map. +var putIntoMu sync.Mutex + // putInto is an assign.Findings Put that keeps each finding in into, as the finding writer would, by its key and its words. func putInto(into map[string][]byte) func(mcseat.Finding) error { return func(f mcseat.Finding) error { raw, err := json.Marshal(f) + putIntoMu.Lock() into[views.FindingKey(f.Scope, f.ID, f.Kind)] = raw + putIntoMu.Unlock() return err } }