From 9707a9d8dd4528c282a37566d75202af37474680 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 10 May 2019 08:54:35 -0700 Subject: [PATCH] client: register before restoring Registration and restoring allocs don't share state or depend on each other in any way (syncing allocs with servers is done outside of registration). Since restoring is synchronous, start the registration goroutine first. For nodes with lots of allocs to restore or close to their heartbeat deadline, this could be the difference between becoming "lost" or not. --- client/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/client.go b/client/client.go index e27db56986d8..b57e8d2860d6 100644 --- a/client/client.go +++ b/client/client.go @@ -442,6 +442,9 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic logger.Warn("batch fingerprint operation timed out; proceeding to register with fingerprinted plugins so far") } + // Register and then start heartbeating to the servers. + c.shutdownGroup.Go(c.registerAndHeartbeat) + // Restore the state if err := c.restoreState(); err != nil { logger.Error("failed to restore state", "error", err) @@ -456,9 +459,6 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic return nil, fmt.Errorf("failed to restore state") } - // Register and then start heartbeating to the servers. - c.shutdownGroup.Go(c.registerAndHeartbeat) - // Begin periodic snapshotting of state. c.shutdownGroup.Go(c.periodicSnapshot)