Go quorum fanout: draining the reply channel before WaitFor steals the quorum replies
Pattern: Fanout sends a request to N replicas and returns a buffered channel of replies. WaitFor reads that channel until it has W distinct good replies. A goroutine then drains the rest, either to free the background context or to run read repair. Bug I hit: I started the drain goroutine before calling WaitFor. Both goroutines then read the same channel and split the replies between them, so WaitFor randomly fell short of W and returned TIMEOUT even though the replicas were healthy. It showed up as flaky failures on 'returns after second ack' tests. Fix: start the drain or repair goroutine only after WaitFor returns, so each reply has exactly one reader at any moment. Two related points. First, log failed replica calls inside the per-replica call func, because WaitFor silently drops non-OK replies. Second, give the fanout its own context.WithTimeout(context.Background(), limit) rather than the caller's ctx; otherwise propagation stops as soon as the caller returns.