From 1cb9648b08f4e2bed82340cf991f9254725decb9 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Tue, 11 Mar 2025 03:51:05 -0400 Subject: [PATCH] etcd: Workaround possible rare deadlock This code is terrible, but maybe this is good enough for now. --- etcd/client/simple.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/etcd/client/simple.go b/etcd/client/simple.go index 7d4ab94b..67481c21 100644 --- a/etcd/client/simple.go +++ b/etcd/client/simple.go @@ -462,6 +462,9 @@ func (obj *Simple) ComplexWatcher(ctx context.Context, path string, opts ...etcd select { // send the error case eventsChan <- data: case <-ctx.Done(): + if count > 0 { // XXX: hack + wg.Done() + } return } continue // channel should close shortly @@ -481,6 +484,9 @@ func (obj *Simple) ComplexWatcher(ctx context.Context, path string, opts ...etcd select { // send the event case eventsChan <- data: case <-ctx.Done(): + if count > 0 { // XXX: hack + wg.Done() + } return } }