@@ -103,7 +103,12 @@ func (re *Relay) Start(globalCtx context.Context) error {
103103 // Start the consumer group worker by trigger a signal to the relay loop to fetch
104104 // a consumer worker to fetch initial healthy node.
105105 re .log .Info ("starting consumer worker" )
106- re .signalCh <- struct {}{}
106+ // The push is non-blocking to avoid getting stuck trying to send on the poll loop
107+ // if the threshold checker go-routine might have already sent on the channel concurrently.
108+ select {
109+ case re .signalCh <- struct {}{}:
110+ default :
111+ }
107112
108113 wg .Add (1 )
109114 // Relay teardown.
@@ -179,7 +184,12 @@ loop:
179184 of , err := re .source .GetHighWatermark (ctx , server .Client )
180185 if err != nil {
181186 re .log .Error ("could not get end offsets (first poll); sending unhealthy signal" , "id" , server .ID , "server" , server .Config .BootstrapBrokers , "error" , err )
182- re .signalCh <- struct {}{}
187+ // The push is non-blocking to avoid getting stuck trying to send on the poll loop
188+ // if the threshold checker go-routine might have already sent on the channel concurrently.
189+ select {
190+ case re .signalCh <- struct {}{}:
191+ default :
192+ }
183193
184194 continue loop
185195 }
@@ -197,7 +207,12 @@ loop:
197207 fetches , err := re .source .GetFetches (server )
198208 if err != nil {
199209 re .log .Error ("marking server as unhealthy" , "server" , server .ID )
200- re .signalCh <- struct {}{}
210+ // The push is non-blocking to avoid getting stuck trying to send on the poll loop
211+ // if the threshold checker go-routine might have already sent on the channel concurrently.
212+ select {
213+ case re .signalCh <- struct {}{}:
214+ default :
215+ }
201216
202217 continue loop
203218 }
0 commit comments