In a scenario where ckb-sync sends a block to ChainService through ChainController::process_block, and at the same time, ChainService receives a Ctrl-C exit signal.
Then ChainService's process_block_sender have one ProcessBlockRequest in its buffer:
However, the process_block_sender is held by the Synchronizer's ChainController, and there is one ProcessBlockRequest in process_block_sender's buffer, causing the ChainController::internal_block_process to block indefinitely.
What problem does this PR solve?
On the develop branch, the
ChainService
'sprocess_block
channel has a capacity ofDEFAULT_CHANNEL_SIZE
(32), but it does not provide any benefit forckb-sync
orckb-chain
: https://github.com/nervosnetwork/ckb/blob/149b5c53e2c6e089d3e4ff6013d1992b56f3b4c6/chain/src/chain.rs#L225In a scenario where
ckb-sync
sends a block toChainService
throughChainController::process_block
, and at the same time,ChainService
receives aCtrl-C
exit signal. ThenChainService
'sprocess_block_sender
have oneProcessBlockRequest
in its buffer:https://github.com/nervosnetwork/ckb/blob/149b5c53e2c6e089d3e4ff6013d1992b56f3b4c6/chain/src/chain.rs#L41
When
self.process_block_sender
andself.stop_receiver
are ready at the same time,ChainService
'sselect!
may choose to executeself.stop_receiver
: https://github.com/nervosnetwork/ckb/blob/149b5c53e2c6e089d3e4ff6013d1992b56f3b4c6/chain/src/chain.rs#L237-L272then the
process_block_receiver
will be dropped.However, the
process_block_sender
is held by theSynchronizer
'sChainController
, and there is oneProcessBlockRequest
inprocess_block_sender
's buffer, causing theChainController::internal_block_process
to block indefinitely.In that case,
Synchronizer::received
will block indefinitely at this point: https://github.com/nervosnetwork/ckb/blob/149b5c53e2c6e089d3e4ff6013d1992b56f3b4c6/sync/src/synchronizer/mod.rs#L784What is changed and how it works?
Related changes
ChainService
's process_block channel capacity size to 0.Check List
Tests
Side effects
Release note