harmony
harmony copied to clipboard
Stream sync stuck with persistent disk cache and single db transaction
Describe the bug If a node uses the disk cache and tries to process a single transaction for the entire sync loop, the sync will break and the node will stop syncing.
To Reproduce Steps to reproduce the behavior:
- Make sure stream sync is enabled
- in config file set the
UseMemDB=false
- set the
canRunCycleInOneTransaction=true
(insyncing.go
underapi/service/stagedstreamsync
) -- later this flag will be set dynamically by PR #4448 - Build
- Let node start syncing from a few thousands blocks behind the network. It won't get any new block and syncing won't go through.
Expected behavior Node has to start syncing process and download the blocks until it reaches to current block
Additional context
The PR #4445 is combining the contexts, which can break disk access for ErigonDB. For example, it removes context.Background()
and replaces it with a common context from stage.
to get the idea what is the reason of using background context, try writing a test with ErigonDB and creating a few goroutines, then commit some data to the same db. Your code has to open up a new transaction with another thread but same database and same context. It will not be able to write to disk while other routines are using the same database.