Commit e7f170c5 authored by Mariusz's avatar Mariusz

Merge branch 'mt-snapshot' of https://gitlab.syncad.com/hive/hive into mt-snapshot

parents 0e834ea1 be64c9fa
......@@ -357,8 +357,9 @@ bool database::is_reindex_complete( uint64_t* head_block_num_origin, uint64_t* h
if( head_block_num_state )
*head_block_num_state = _head_block_num_state;
FC_ASSERT( _head_block_num_state <= _head_block_num_origin, "Incorrect number of blocks in `block_log` vs `state`. { \"block_log-head\": ${b1}, \"state-head\": ${b2} }",
( "b1", _head_block_num_origin )( "b2", _head_block_num_state ) );
if( _head_block_num_state > _head_block_num_origin )
elog( "Incorrect number of blocks in `block_log` vs `state`. { \"block_log-head\": ${b1}, \"state-head\": ${b2} }",
( "b1", _head_block_num_origin )( "b2", _head_block_num_state ) );
return _head_block_num_origin == _head_block_num_state;
}
......
......@@ -691,6 +691,16 @@ namespace hive { namespace chain {
_sps_remove_threshold = val;
}
int16_t get_snapshot_loaded() const
{
return snapshot_loaded;
}
void set_snapshot_loaded()
{
snapshot_loaded = true;
}
util::advanced_benchmark_dumper& get_benchmark_dumper()
{
return _benchmark_dumper;
......@@ -735,6 +745,8 @@ namespace hive { namespace chain {
uint16_t _shared_file_scale_rate = 0;
int16_t _sps_remove_threshold = -1;
bool snapshot_loaded = false;
flat_map< custom_id_type, std::shared_ptr< custom_operation_interpreter > > _custom_operation_interpreters;
std::string _json_schema;
......
......@@ -994,6 +994,8 @@ namespace chainbase {
}
};
void wipe_indexes();
public:
void open( const bfs::path& dir, uint32_t flags = 0, size_t shared_file_size = 0, const boost::any& database_cfg = nullptr, const helpers::environment_extension_resources* environment_extension = nullptr );
void close();
......
......@@ -293,6 +293,9 @@ size_t snapshot_base_serializer::worker_common_base::get_serialized_object_cache
_segment.reset();
_meta.reset();
_data_dir = bfs::path();
wipe_indexes();
#else
undo_all();
......@@ -300,11 +303,18 @@ size_t snapshot_base_serializer::worker_common_base::get_serialized_object_cache
{
item->close();
}
wipe_indexes();
#endif
_is_open = false;
}
}
void database::wipe_indexes()
{
_index_list.clear();
_index_map.clear();
}
void database::wipe( const bfs::path& dir )
{
assert( !_is_open );
......@@ -314,16 +324,17 @@ size_t snapshot_base_serializer::worker_common_base::get_serialized_object_cache
bfs::remove_all( dir / "shared_memory.bin" );
bfs::remove_all( dir / "shared_memory.meta" );
_data_dir = bfs::path();
_index_list.clear();
_index_map.clear();
wipe_indexes();
#else
for( auto& item : _index_list )
{
item->wipe( dir );
}
_index_list.clear();
_index_map.clear();
wipe_indexes();
_index_types.clear();
#endif
}
......@@ -339,8 +350,7 @@ size_t snapshot_base_serializer::worker_common_base::get_serialized_object_cache
open( _data_dir, 0, new_shared_file_size );
_index_list.clear();
_index_map.clear();
wipe_indexes();
for( auto& index_type : _index_types )
{
......
This diff is collapsed.
......@@ -19,7 +19,7 @@ class state_snapshot_plugin final : public appbase::plugin< state_snapshot_plugi
public:
APPBASE_PLUGIN_REQUIRES((hive::plugins::chain::chain_plugin))
static const std::string& name() { static std::string name = "state_snapshot_plugin"; return name; }
static const std::string& name() { static std::string name = "state_snapshot"; return name; }
state_snapshot_plugin();
virtual ~state_snapshot_plugin();
......
......@@ -1024,6 +1024,15 @@ void state_snapshot_plugin::impl::prepare_snapshot(const std::string& snapshotNa
if(bfs::exists(actualStoragePath) == false)
bfs::create_directories(actualStoragePath);
else
{
if( !bfs::is_empty(actualStoragePath) )
{
wlog("Directory ${p} is not empty. Creating snapshot rejected.", ("p", actualStoragePath.string()));
return;
}
}
const auto& indices = _mainDb.get_abstract_index_cntr();
......@@ -1141,6 +1150,8 @@ void state_snapshot_plugin::impl::load_snapshot(const std::string& snapshotName,
ilog("Snapshot loading finished, starting validate_invariants to check consistency...");
_mainDb.validate_invariants();
ilog("Validate_invariants finished...");
_mainDb.set_snapshot_loaded();
}
void state_snapshot_plugin::impl::process_explicit_snapshot_requests(const hive::chain::open_args& openArgs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment