From 4634d00f8d9b06db47c958508828288c29dc74eb Mon Sep 17 00:00:00 2001 From: Maxime Fischer Date: Tue, 14 Nov 2023 14:24:35 +0000 Subject: [PATCH] Start receiving from queue only once we got all inflight executions. (#269) * Receive from queue after getting list of jobs. --- ChangeLog | 5 +++++ VERSION | 2 +- mettle/api/api.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0218e592..6ef67f8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Version 11.6.3 +-------------- + * Start receiving from queue only once we got all inflight executions. + This should fix a potential data race on init. + Version 11.6.2 -------------- * Error token bucket was mistakenly consuming with `Allow()`. Refactored to make token bucket behaviour correct. diff --git a/VERSION b/VERSION index 48f8d64e..546fe235 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -11.6.2 +11.6.3 diff --git a/mettle/api/api.go b/mettle/api/api.go index cf75673d..1c480021 100644 --- a/mettle/api/api.go +++ b/mettle/api/api.go @@ -169,7 +169,6 @@ func serve(opts grpcutil.Opts, name string, queueOpts PubSubOpts, apiURL string, log.Notice(" %s: %s", k, strings.Join(v, ", ")) } - go srv.Receive() if jobs, err := getExecutions(opts, apiURL, connTLS); err != nil { log.Warningf("Failed to get inflight executions: %s", err) } else if len(jobs) > 0 { @@ -180,6 +179,7 @@ func serve(opts grpcutil.Opts, name string, queueOpts PubSubOpts, apiURL string, go srv.expireJob(id) } } + go srv.Receive() lis, s := grpcutil.NewServer(opts) pb.RegisterCapabilitiesServer(s, srv)