core, ethdb: introduce database sync function (#31703)#3117
Merged
zzzckck merged 1 commit intobnb-chain:developfrom May 28, 2025
buddh0:port-db-sync-fix
Merged
core, ethdb: introduce database sync function (#31703)#3117zzzckck merged 1 commit intobnb-chain:developfrom buddh0:port-db-sync-fix
zzzckck merged 1 commit intobnb-chain:developfrom
buddh0:port-db-sync-fix
Conversation
This pull request introduces a SyncKeyValue function to the ethdb.KeyValueStore interface, providing the ability to forcibly flush all previous writes to disk. This functionality is critical for go-ethereum, which internally uses two independent database engines: a key-value store (such as Pebble, LevelDB, or memoryDB for testing) and a flat-file–based freezer. To ensure write-order consistency between these engines, the key-value store must be explicitly synced before writing to the freezer and vice versa. Fixes - ethereum/go-ethereum#31405 - ethereum/go-ethereum#29819
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new database sync functions to improve durability guarantees after a force kill by replacing the existing Sync API with distinct methods (SyncKeyValue and SyncAncient) and updates related call sites and documentation. Key changes include removing the ephemeral flag from the pebble.New function, adding dedicated sync methods for key-value and ancient data stores, and updating tests and dependent modules accordingly.
- Removed the ephemeral parameter from the pebble.New API.
- Introduced SyncKeyValue and SyncAncient functions across various database implementations.
- Updated call sites in core and test packages to use the new sync methods.
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ethdb/pebble/pebble.go | Updated New signature and async write comments |
| ethdb/memorydb/memorydb.go | Added no-op SyncKeyValue method |
| ethdb/leveldb/leveldb.go | Added no-op SyncKeyValue method |
| ethdb/database.go | Introduced KeyValueSyncer interface and removed legacy Sync methods |
| core/rawdb/* | Renamed Sync to SyncAncient and updated passthrough methods |
| core/blockchain* | Updated pebble.New calls to remove the ephemeral flag |
| cmd/geth/dbcmd.go | Updated BlockStore sync call to use SyncAncient |
Comments suppressed due to low confidence (2)
core/rawdb/freezer.go:391
- The Sync method call on table should be updated to SyncAncient to match the new API naming, ensuring consistency and expected functionality.
if err := table.Sync(); err != nil {
ethdb/pebble/pebble.go:149
- The ephemeral parameter has been removed from the New function signature; please ensure that all related documentation and caller updates reflect this change.
func New(file string, cache int, handles int, namespace string, readonly bool) (*Database, error) {
zzzckck
approved these changes
May 27, 2025
galaio
approved these changes
May 28, 2025
This was referenced May 28, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
core, ethdb: introduce database sync function
Rationale
new release v1.5.13 will sync from block 0 after
force killedtry to fix this by cherry-picking ethereum/go-ethereum#31703
Example
add an example CLI or API response...
Changes
Notable changes: