Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexerService::apply_init_tip should stop after received exit signal. #4345

Merged
merged 3 commits into from
Feb 8, 2024

Conversation

eval-exec
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close #4311

Problem Summary:

In the apply_init_tip function, there is a loop that should take into account the exit signal:

loop {
if let Err(e) = self.secondary_db.try_catch_up_with_primary() {
error!("secondary_db try_catch_up_with_primary error {}", e);
}
if let Some(header) = self.secondary_db.get_block_header(&init_tip_hash.pack()) {
let init_tip_number = header.number();
let mut batch = self.store.batch().expect("create batch should be OK");
batch
.put_kv(
Key::Header(init_tip_number, &init_tip_hash.pack(), true),
vec![],
)
.expect("insert init tip header should be OK");
batch.commit().expect("commit batch should be OK");
break;
}
sleep(Duration::from_secs(1));

Additionally, once initial_syncing is finished and CKB receives an exit signal, there is no need to spawn the new_block_watcher polling job.

What's Changed:

Related changes

  • handle exit signal in apply_init_tip

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Side effects

  • None

Release note

Title Only: Include only the PR title in the release note.

@eval-exec eval-exec requested a review from a team as a code owner February 8, 2024 10:33
@quake quake enabled auto-merge February 8, 2024 11:10
@quake quake added this pull request to the merge queue Feb 8, 2024
Merged via the queue into nervosnetwork:develop with commit 4fbba9a Feb 8, 2024
32 checks passed
@15168316096
Copy link
Contributor

15168316096 commented Feb 8, 2024

Review verification passed, ctrl c can exit the ckb process normally, the relevant log content is as follows:

^C2024-02-08 12:20:58.267 +00:00 ctrl-c INFO ckb_bin::subcommand::run  Trapped exit signal, exiting...
2024-02-08 12:20:58.267 +00:00 ctrl-c DEBUG ckb_stop_handler::stop_register  Received exit signal; broadcasting exit signal to all threads
2024-02-08 12:20:58.267 +00:00 GlobalRt-6 INFO ckb_tx_pool::chunk_process  TxPool chunk_command service received exit signal, exit now
2024-02-08 12:20:58.267 +00:00 GlobalRt-5 INFO ckb_sync::types::header_map  HeaderMap limit_memory received exit signal, exit now
2024-02-08 12:20:58.267 +00:00 main DEBUG ckb_stop_handler::stop_register  wait_all_ckb_services_exit waiting all threads to exit
2024-02-08 12:20:58.267 +00:00 GlobalRt-5 INFO ckb_tx_pool::service  TxPool reorg process service received exit signal, exit now
2024-02-08 12:20:58.267 +00:00 GlobalRt-8 INFO ckb_tx_pool::service  TxPool block_assembler process service received exit signal, exit now
2024-02-08 12:20:58.267 +00:00 GlobalRt-5 DEBUG hyper::server::shutdown  signal received, starting graceful shutdown
2024-02-08 12:20:58.268 +00:00 GlobalRt-8 INFO ckb_block_filter::filter  BlockFilter received exit signal, exit now
2024-02-08 12:20:58.268 +00:00 GlobalRt-6 INFO ckb_notify  NotifyService received exit signal, exit now
2024-02-08 12:20:58.267 +00:00 ChainService INFO ckb_chain::chain  ChainService received exit signal, exit now
2024-02-08 12:20:58.268 +00:00 GlobalRt-11 INFO ckb_tx_pool::service  TxPool is saving, please wait...
2024-02-08 12:20:58.268 +00:00 GlobalRt-1 INFO ckb_network::network  NetworkService receive exit signal, start shutdown...
2024-02-08 12:20:58.268 +00:00 GlobalRt-1 INFO ckb_network::network  NetworkService shutdown now
2024-02-08 12:20:58.268 +00:00 GlobalRt-1 DEBUG tentacle::service  shutdown because all state is empty head
2024-02-08 12:20:58.268 +00:00 GlobalRt-1 DEBUG tentacle::service::future_task  future task finished because service shutdown
2024-02-08 12:20:58.268 +00:00 GlobalRt-5 INFO ckb_network::network  p2p service event: ListenClose { address: "/ip4/0.0.0.0/tcp/8127" }
2024-02-08 12:20:58.268 +00:00 GlobalRt-0 DEBUG ckb_network::services::dump_peer_store  Dump peer store before exiting
2024-02-08 12:20:58.268 +00:00 GlobalRt-0 DEBUG ckb_network::peer_store::peer_store_db  Dump 0 addrs
2024-02-08 12:20:58.268 +00:00 GlobalRt-1 DEBUG sled::pagecache::logger  IoBufs dropped
2024-02-08 12:20:58.268 +00:00 main INFO ckb_stop_handler::stop_register  Waiting thread ChainService done.
2024-02-08 12:20:58.268 +00:00 main DEBUG ckb_stop_handler::stop_register  All ckb threads have been stopped.
2024-02-08 12:20:58.268 +00:00 main INFO ckb_bin  Waiting for all tokio tasks to exit...
2024-02-08 12:20:58.271 +00:00 GlobalRt-11 INFO ckb_tx_pool::process  TxPool saved successfully
2024-02-08 12:20:58.271 +00:00 GlobalRt-11 INFO ckb_tx_pool::service  TxPool process_service exit now
2024-02-08 12:20:58.272 +00:00 GlobalRt-0 DEBUG ckb_network::peer_store::peer_store_db  Dump 0 banned addrs
2024-02-08 12:20:58.274 +00:00 GlobalRt-0 DEBUG ckb_network::services::dump_peer_store  Dump peer store to "/home/ckb/xueyl/ckb/ckb_v0.114.0-rc1_x86_64-unknown-linux-gnu/data/network/peer_store"
2024-02-08 12:20:58.816 +00:00 GlobalRt-16 INFO ckb_indexer::service  apply_init_tip received exit signal, exit now
2024-02-08 12:20:59.165 +00:00 GlobalRt-11 INFO ckb_indexer::service  initial_syncing finished
2024-02-08 12:20:59.165 +00:00 GlobalRt-11 INFO ckb_indexer::service  Indexer received exit signal, cancel new_block_watcher task, exit now
2024-02-08 12:20:59.166 +00:00 main INFO ckb_bin  All tokio tasks and threads have exited. CKB shutdown```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CKB Node fails to shutdown properly.
3 participants