harmony icon indicating copy to clipboard operation
harmony copied to clipboard

Stream sync stuck with persistent disk cache and single db transaction

Open GheisMohammadi opened this issue 1 year ago • 0 comments

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:

  1. Make sure stream sync is enabled
  2. in config file set the UseMemDB=false
  3. set the canRunCycleInOneTransaction=true (in syncing.go under api/service/stagedstreamsync) -- later this flag will be set dynamically by PR #4448
  4. Build
  5. 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.

GheisMohammadi avatar Jun 19 '23 10:06 GheisMohammadi