Skip to content

Commit

Permalink
fix: State Sync no longer corrupts the DB (#8732)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nikurt authored Mar 16, 2023
1 parent f90cd9c commit 8ff99fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down
4 changes: 3 additions & 1 deletion chain/client/src/client_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}

Expand Down

0 comments on commit 8ff99fe

Please sign in to comment.