HomePhabricator

validation: delay flushing undo files in syncing node case

Description

validation: delay flushing undo files in syncing node case

Summary:
Data files are pre-allocated, and upon flush/finalization, they are trimmed down to their resulting size.
Block (blk) files are written to disk as blocks come in, which is often out of order, whereas undo (rev) files are written sequentially, as each block is added to the top of the chain.
When a block file hits the size limit, the system flushes and trims the file down to its final size, and moves on to the next block file.

Case 1: blocks are added to the chain as they come in (synced up node case) -- in this case, we will flush and finalize the undo file together with the block file.

Case 2: blocks are added to the chain after they have been downloaded (syncing node case) -- in this case, we postpone finalizing the undo file until we know the undo data for the last block in the file has been written to disk.

This is a backport of core#17994

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

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

Details

Provenance
Karl-Johan Alm <karljohan-alm@garage.co.jp>Authored on Jan 24 2020, 04:02
PiRKCommitted on Mar 1 2021, 14:44
PiRKPushed on Mar 1 2021, 14:44
Reviewer
Restricted Project
Differential Revision
D9275: validation: delay flushing undo files in syncing node case
Parents
rABCc9c716200e6e: refactor: Replace RecursiveMutex with Mutex in Shutdown()
Branches
Unknown
Tags
Unknown