Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChainDB: store a ledger snapshot on startup after a long replay #1956

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Apr 15, 2020

The LgrDB decides to make snapshots based on the time passed and the number of
blocks advanced since the last snapshot. When it had to replay blocks on
startup because the on-disk snapshots were out of date or missing, that number
of replayed blocks is taken into account for the decision to make the next
snapshot (as the starting point for the number of blocks advanced).

However, the decision making logic is only triggered after copying a block
to the ImmutableDB. So, for example, when starting a node with lots of blocks,
but without on-disk ledger snapshots, it will replay all blocks to reconstruct
an up-to-date ledger state, but it won't write it to disk until a block has
been copied to the ImmutableDB. When experimenting, one often has a node that
no longer downloads blocks acting as a server node, so that node will never
write its snapshot to disk. This means a full ledger replay has to be done on
every startup.

Fix this by triggering the snapshot making logic before starting the loop that
waits for blocks being copied to the ImmutableDB.

The LgrDB decides to make snapshots based on the time passed and the number of
blocks advanced since the last snapshot. When it had to replay blocks on
startup because the on-disk snapshots were out of date or missing, that number
of replayed blocks is taken into account for the decision to make the next
snapshot (as the starting point for the number of blocks advanced).

However, the decision making logic is only triggered *after* copying a block
to the ImmutableDB. So, for example, when starting a node with lots of blocks,
but without on-disk ledger snapshots, it will replay all blocks to reconstruct
an up-to-date ledger state, but it won't write it to disk until a block has
been copied to the ImmutableDB. When experimenting, one often has a node that
no longer downloads blocks acting as a server node, so that node will never
write its snapshot to disk. This means a full ledger replay has to be done on
every startup.

Fix this by triggering the snapshot making logic before starting the loop that
waits for blocks being copied to the ImmutableDB.
@mrBliss mrBliss added the consensus issues related to ouroboros-consensus label Apr 15, 2020
@mrBliss mrBliss requested a review from edsko April 15, 2020 16:20
@mrBliss
Copy link
Contributor Author

mrBliss commented Apr 15, 2020

bors merge

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Apr 15, 2020

@iohk-bors iohk-bors bot merged commit 742898d into master Apr 15, 2020
@iohk-bors iohk-bors bot deleted the mrBliss/write-snapshot-after-startup branch April 15, 2020 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants