Skip to content

Commit

Permalink
fix receive router deadlock on interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
fgouteroux committed May 8, 2022
1 parent c4f4fe4 commit 08a960c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ func runReceive(
reloadGRPCServer := make(chan struct{}, 1)
// hashringChangedChan signals when TSDB needs to be flushed and updated due to hashring config change.
hashringChangedChan := make(chan struct{}, 1)
// uploadC signals when new blocks should be uploaded.
uploadC := make(chan struct{}, 1)
// uploadDone signals when uploading has finished.
uploadDone := make(chan struct{}, 1)

if enableIngestion {
// uploadC signals when new blocks should be uploaded.
uploadC := make(chan struct{}, 1)
// uploadDone signals when uploading has finished.
uploadDone := make(chan struct{}, 1)

level.Debug(logger).Log("msg", "setting up tsdb")
{
if err := startTSDBAndUpload(g, logger, reg, dbs, reloadGRPCServer, uploadC, hashringChangedChan, upload, uploadDone, statusProber, bkt); err != nil {
Expand Down Expand Up @@ -370,7 +371,9 @@ func setupAndRunGRPCServer(g *run.Group,
}
}
return nil
}, func(error) {})
}, func(error) {
defer close(reloadGRPCServer)
})

return nil

Expand Down Expand Up @@ -516,7 +519,6 @@ func startTSDBAndUpload(g *run.Group,
// TSDBs reload logic, listening on hashring changes.
cancel := make(chan struct{})
g.Add(func() error {
defer close(reloadGRPCServer)
defer close(uploadC)

// Before quitting, ensure the WAL is flushed and the DBs are closed.
Expand Down

0 comments on commit 08a960c

Please sign in to comment.