Skip to content

Commit 52c236a

Browse files
authored
Merge pull request #1134 from AntelopeIO/GH-1125-replay-interrupt
Do not interrupt apply_block during replay
2 parents 7121d54 + 5f7ed95 commit 52c236a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libraries/chain/controller.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ struct controller_impl {
990990
// persist chain_head after vote_processor shutdown, avoids concurrent access, after chain_head & conf since this uses them
991991
fc::scoped_exit<std::function<void()>> write_chain_head = [&]() { chain_head.write(conf.state_dir / config::chain_head_filename); };
992992
const chain_id_type chain_id; // read by thread_pool threads, value will not be changed
993-
bool replaying = false;
993+
std::atomic<bool> replaying = false;
994994
bool is_producer_node = false; // true if node is configured as a block producer
995995
block_num_type pause_at_block_num = std::numeric_limits<block_num_type>::max();
996996
const db_read_mode read_mode;
@@ -1751,7 +1751,8 @@ struct controller_impl {
17511751
}
17521752
transition_legacy_branch.clear(); // not needed after replay
17531753
auto end = fc::time_point::now();
1754-
ilog( "${n} irreversible blocks replayed from block log", ("n", 1 + chain_head.block_num() - start_block_num) );
1754+
ilog( "${n} irreversible blocks replayed from block log, chain head ${bn}",
1755+
("n", 1 + chain_head.block_num() - start_block_num)("bn", chain_head.block_num()) );
17551756
ilog( "replayed ${n} blocks in ${duration} seconds, ${mspb} ms/block",
17561757
("n", chain_head.block_num() + 1 - start_block_num)("duration", (end-start).count()/1000000)
17571758
("mspb", ((end-start).count()/1000.0)/(chain_head.block_num()-start_block_num)) );
@@ -2050,7 +2051,8 @@ struct controller_impl {
20502051
ilog( "chain database started with hash: ${hash}", ("hash", calculate_integrity_hash()) );
20512052
okay_to_print_integrity_hash_on_stop = true;
20522053

2053-
fc::scoped_set_value r(replaying, true);
2054+
replaying = true;
2055+
auto replay_reset = fc::make_scoped_exit([&](){ replaying = false; });
20542056
replay( startup ); // replay any irreversible and reversible blocks ahead of current head
20552057

20562058
if( check_shutdown() ) return;
@@ -4533,7 +4535,7 @@ struct controller_impl {
45334535
// Only interrupt transaction if applying a block. Speculative trxs already have a deadline set so they
45344536
// have limited run time already. This is to allow killing a long-running transaction in a block being
45354537
// validated.
4536-
if (applying_block) {
4538+
if (!replaying && applying_block) {
45374539
ilog("Interrupting apply block");
45384540
main_thread_timer.interrupt_timer();
45394541
}

0 commit comments

Comments
 (0)