From b5f73b6aab9406ad8f819c8f851370d2971894d6 Mon Sep 17 00:00:00 2001 From: Antioch Peverell Date: Tue, 10 Dec 2019 16:16:59 +0000 Subject: [PATCH] try_header_head in the syncer loop with a short timeout (#3165) to prevent it getting locked up after txhashset download and validation --- servers/src/grin/sync/syncer.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/servers/src/grin/sync/syncer.rs b/servers/src/grin/sync/syncer.rs index 578e98fc1..68f9f4f5d 100644 --- a/servers/src/grin/sync/syncer.rs +++ b/servers/src/grin/sync/syncer.rs @@ -182,7 +182,18 @@ impl SyncRunner { // if syncing is needed let head = unwrap_or_restart_loop!(self.chain.head()); let tail = self.chain.tail().unwrap_or_else(|_| head.clone()); - let header_head = unwrap_or_restart_loop!(self.chain.header_head()); + + // We still do not fully understand what is blocking this but if this blocks here after + // we download and validate the txhashet we do not reliably proceed to block_sync, + // potentially blocking for an extended period of time (> 10 mins). + // Does not appear to be deadlock as it does resolve itself eventually. + // So as a workaround we try_header_head with a relatively short timeout and simply + // retry the syncer loop. + let maybe_header_head = + unwrap_or_restart_loop!(self.chain.try_header_head(time::Duration::from_secs(1))); + let header_head = unwrap_or_restart_loop!( + maybe_header_head.ok_or("failed to obtain lock for try_header_head") + ); // run each sync stage, each of them deciding whether they're needed // except for state sync that only runs if body sync return true (means txhashset is needed)