Skip to content

Commit

Permalink
Merge pull request #4346 from eval-exec/exec/rc/v0.114.x-4345
Browse files Browse the repository at this point in the history
Backport to `v0.114.x` , `IndexerService::apply_init_tip` should stop after received exit signal.
  • Loading branch information
doitian authored Feb 18, 2024
2 parents 3846d45 + ecd687e commit 708f2b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions util/indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ckb-notify = { path = "../../notify", version = "= 0.114.0-rc1" }
ckb-store = { path = "../../store", version = "= 0.114.0-rc1" }
ckb-stop-handler = { path = "../stop-handler", version = "= 0.114.0-rc1" }
ckb-async-runtime = { path = "../runtime", version = "= 0.114.0-rc1" }
ckb-channel = { path = "../channel", version = "= 0.114.0-rc1" }
rhai = { version = "1.10.0", features = ["no_function", "no_float", "no_module", "sync"]}
serde_json = "1.0"
numext-fixed-uint = "0.1"
Expand Down
17 changes: 16 additions & 1 deletion util/indexer/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use ckb_jsonrpc_types::{
};
use ckb_logger::{error, info};
use ckb_notify::NotifyController;
use ckb_stop_handler::{new_tokio_exit_rx, CancellationToken};
use ckb_stop_handler::{new_crossbeam_exit_rx, new_tokio_exit_rx, CancellationToken};
use ckb_store::ChainStore;
use ckb_types::{
core::{self, BlockNumber},
Expand Down Expand Up @@ -153,7 +153,16 @@ impl IndexerService {
}
}
}
let stop_rx = new_crossbeam_exit_rx();
loop {
ckb_channel::select! {
recv(stop_rx) -> _ =>{
info!("apply_init_tip received exit signal, exit now");
break;
},
default() => {},
}

if let Err(e) = self.secondary_db.try_catch_up_with_primary() {
error!("secondary_db try_catch_up_with_primary error {}", e);
}
Expand Down Expand Up @@ -228,6 +237,12 @@ impl IndexerService {
let poll_service = self.clone();
self.async_handle.spawn(async move {
let _initial_finished = initial_syncing.await;
info!("initial_syncing finished");
if stop.is_cancelled() {
info!("Indexer received exit signal, cancel new_block_watcher task, exit now");
return;
}

let mut new_block_watcher = notify_controller
.watch_new_block(SUBSCRIBER_NAME.to_string())
.await;
Expand Down

0 comments on commit 708f2b2

Please sign in to comment.