From abae9d449d270d9912251953fb6f23732b914f86 Mon Sep 17 00:00:00 2001 From: Keke Li Date: Tue, 7 Dec 2021 18:38:23 -0800 Subject: [PATCH] Eixt nodeos gracefully if db size is smaller than snapshot size --- libraries/chain/controller.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 0f98f2d59d5..4a1d99205a8 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -506,6 +506,7 @@ struct controller_impl { "chainbase is at revision ${a}, but chain-kv is at revision ${b}", ("a", db.revision())("b", kv_db.revision()) ); this->shutdown = shutdown; ilog( "Starting initialization from snapshot, this may take a significant amount of time" ); + bool exception = false; try { snapshot->validate(); if( blog.head() ) { @@ -528,10 +529,14 @@ struct controller_impl { init(check_shutdown, true); } catch (boost::interprocess::bad_alloc& e) { elog( "db storage not configured to have enough storage for the provided snapshot, please increase and retry snapshot" ); - throw e; + shutdown(); + exception = true; } - ilog( "Finished initialization from snapshot" ); + if(!exception) + ilog ( "Finished initialization from snapshot" ); + else + elog ( "Failed initialization from snapshot" ); } void startup(std::function shutdown, std::function check_shutdown, const genesis_state& genesis) {