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

Snapshot bundle cleanup across CAPI #2678

Open
battlmonstr opened this issue Jan 27, 2025 · 0 comments
Open

Snapshot bundle cleanup across CAPI #2678

battlmonstr opened this issue Jan 27, 2025 · 0 comments
Labels
c api The C API exposed for Erigon erigon3 Erigon3 feature snapshots Framework for BitTorrent-based snapshots

Comments

@battlmonstr
Copy link
Contributor

Erigon has a reference counter attached to snapshot files in use by AggregatorRoTx. When AggregatorRoTx is closed (using Close()) it triggers a scheduled cleanup of files that have been merged into bigger files (closeFilesAndRemove). If AggregatorRoTx is not opened, refcount is zero and closeFilesAndRemove happens immediately after merging (deleteMergeFile).

Currently this is not coordinated with silkworm. While using snapshot files managed by erigon, silkworm is not beginning an AggregatorRoTx. If the files are merged, they will be unmapped, closed and deleted (mmap.Munmap). At this point SnapshotRepository will contain dangling references that will lead to errors or crashes.

We need to care about the following:

  1. If snapshot files are currently in use by a datastore query, the usage refcount must be incremented on the Erigon side to prevent cleanup. When snapshot files are no longer in use - decrement refcount.
  2. If files are cleaned up by Erigon, they must be removed from SnapshotRepository.
@battlmonstr battlmonstr added c api The C API exposed for Erigon erigon3 Erigon3 feature snapshots Framework for BitTorrent-based snapshots labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c api The C API exposed for Erigon erigon3 Erigon3 feature snapshots Framework for BitTorrent-based snapshots
Projects
None yet
Development

No branches or pull requests

1 participant