Skip to content

Commit

Permalink
receive: race condition in handler Close() when stopped early (thanos…
Browse files Browse the repository at this point in the history
…-io#7087)

Receiver hangs waiting for the HTTP Hander to shutdown if an error occurs
before Handler is initialized. This might happen, for example, if the hashring
is too small for a given replication factor.

Signed-off-by: Mikhail Nozdrachev <[email protected]>
  • Loading branch information
cincinnat authored and hczhu-db committed Aug 22, 2024
1 parent 1127d01 commit f6a9f45
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/receive/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1786,3 +1786,12 @@ func TestHandlerFlippingHashrings(t *testing.T) {
cancel()
wg.Wait()
}

func TestHandlerEarlyStop(t *testing.T) {
h := NewHandler(nil, &Options{})
h.Close()

err := h.Run()
testutil.NotOk(t, err)
testutil.Equals(t, "http: Server closed", err.Error())
}

0 comments on commit f6a9f45

Please sign in to comment.