Skip to content

Commit

Permalink
Fix memqueue getting stuck on shutdown
Browse files Browse the repository at this point in the history
There was a case when openState.publish could get stuck and ignore its
shutdown signal, effectively preventing a Beat from gracefully
terminating.

This commit fixes this by ensuring every channel read/write also
checks for the shutdown signal.
  • Loading branch information
belimawr committed Nov 9, 2023
1 parent 28152d5 commit abcc42e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libbeat/publisher/queue/memqueue/produce.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@ func (st *openState) Close() {
func (st *openState) publish(req pushRequest) (queue.EntryID, bool) {
select {
case st.events <- req:
return <-req.resp, true
select {
case resp := <-req.resp:
return resp, true
case <-st.done:
st.events = nil
return 0, false
}
case <-st.done:
st.events = nil
return 0, false
Expand Down

0 comments on commit abcc42e

Please sign in to comment.