Skip to content

Commit ba144b2

Browse files
committed
Start the query frontend worker after the querier has been successfully initialized
Signed-off-by: Marco Pracucci <marco@pracucci.com>
1 parent b69f799 commit ba144b2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/cortex/modules.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ func (t *Cortex) stopDistributor() (err error) {
195195
}
196196

197197
func (t *Cortex) initQuerier(cfg *Config) (err error) {
198-
t.worker, err = frontend.NewWorker(cfg.Worker, httpgrpc_server.NewServer(t.server.HTTPServer.Handler), util.Logger)
199-
if err != nil {
200-
return
201-
}
202-
203198
var store querier.ChunkStore
204199

205200
if cfg.Storage.Engine == storage.StorageEngineTSDB {
@@ -237,6 +232,13 @@ func (t *Cortex) initQuerier(cfg *Config) (err error) {
237232
subrouter.Path("/chunks").Handler(t.httpAuthMiddleware.Wrap(querier.ChunksHandler(queryable)))
238233
subrouter.Path("/user_stats").Handler(middleware.AuthenticateUser.Wrap(http.HandlerFunc(t.distributor.UserStatsHandler)))
239234

235+
// Start the query frontend worker once the query engine and the store
236+
// have been successfully initialized.
237+
t.worker, err = frontend.NewWorker(cfg.Worker, httpgrpc_server.NewServer(t.server.HTTPServer.Handler), util.Logger)
238+
if err != nil {
239+
return
240+
}
241+
240242
// Once the execution reaches this point, all synchronous initialization has been
241243
// done and the querier is ready to serve queries, so we're just returning a 202.
242244
t.server.HTTP.Path("/ready").Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)