HomePhabricator

[Chronik] Add `/pause` and `/resume` endpoints

Description

[Chronik] Add /pause and /resume endpoints

Summary:
Background: This is added so we can reproduce the bug in D14361. It only occurs when Chronik is lagging behind the node, so to simulate this, we allow pausing and resuming Chronik indexing.

Note that this only pauses the indexing, querying the indexer still works fine (it might return old data though).

A commented-out reproduction of the bug mentioned in D14361 can be found in chronik_pause.py, this should be uncommented once the bug is fixed.

We enable pausing in Chronik by adding a pair of Pause and PauseNotify structs:

  • Pause::block_if_paused allows blocking the thread if paused, until resumed by PauseNotify.
  • PauseNotify blocks subsequent calls to Pause::block_if_paused, or resumes them.

Since we use the newer wait_for function of tokio, we update the tokio version to the most recent version.

Pause doesn't need to be behind any lock, so it won't result in a deadlock when e.g. trying to read from Chronik.

However, any call to SyncWithValidationInterfaceQueue while paused would block forever; this means we can't use the RPC methods like sendrawtransaction, submitblock, invalidateblock etc., we can however use the P2P network directly, e.g. with send_txs_and_test and send_blocks_and_test.

Test Plan: ninja && ./test/functional/test_runner.py chronik_pause

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D14386

Details

Provenance
tobias_ruckAuthored on Aug 18 2023, 05:36
tobias_ruckPushed on Aug 18 2023, 14:39
Reviewer
Restricted Project
Differential Revision
D14386: [Chronik] Add `/pause` and `/resume` endpoints
Parents
rABCb1476c7ef0db: [electrum] add tests for command line preprocessing
Branches
Unknown
Tags
Unknown