Skip to content

Commit

Permalink
fix receive router deadlock on interrupt
Browse files Browse the repository at this point in the history
Signed-off-by: François Gouteroux <francois.gouteroux@gmail.com>
  • Loading branch information
fgouteroux committed May 8, 2022
1 parent c4f4fe4 commit 5e77671
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/thanos/receive.go
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 5e77671

Please sign in to comment.