From 8ff99fe9b4fbd9ff2847da42f151b6af94d5f53d Mon Sep 17 00:00:00 2001 From: nikurt <86772482+nikurt@users.noreply.github.com> Date: Thu, 16 Mar 2023 09:00:17 +0100 Subject: [PATCH] fix: State Sync no longer corrupts the DB (#8732) If a node gets stopped during State Sync then it fails to start due to an `unwrap()` on `send_network_chain_info()`. The state of the DB itself is fine. This PR makes the node gracefully handle that scenario and State Sync can safely resume and complete. Fix: #8733 --- CHANGELOG.md | 1 + chain/client/src/client.rs | 2 +- chain/client/src/client_actor.rs | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 044ca48c442..1818d922c64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * Experimental option to dump state of every epoch to external storage. [#8661](https://github.com/near/nearcore/pull/8661) * State-viewer tool to dump and apply state changes from/to a range of blocks [#8628](https://github.com/near/nearcore/pull/8628) +* Node can restart if State Sync gets interrupted [#8732](https://github.com/near/nearcore/pull/8732) ## 1.32.0 diff --git a/chain/client/src/client.rs b/chain/client/src/client.rs index cd9373afe07..60abc3ef7bc 100644 --- a/chain/client/src/client.rs +++ b/chain/client/src/client.rs @@ -1454,7 +1454,7 @@ impl Client { // send_network_chain_info should be called whenever the chain head changes. // See send_network_chain_info() for more details. if let Err(err) = self.send_network_chain_info() { - error!(target:"client","Failed to update network chain info: {err}"); + error!(target: "client", ?err, "Failed to update network chain info"); } } diff --git a/chain/client/src/client_actor.rs b/chain/client/src/client_actor.rs index 382f1e5bc10..bc39e8fba1f 100644 --- a/chain/client/src/client_actor.rs +++ b/chain/client/src/client_actor.rs @@ -255,7 +255,9 @@ impl Actor for ClientActor { // Start catchup job. self.catchup(ctx); - self.client.send_network_chain_info().unwrap(); + if let Err(err) = self.client.send_network_chain_info() { + error!(target: "client", ?err, "Failed to update network chain info"); + } } }