Skip to content

core, ethdb: introduce database sync function (#31703)#3117

Merged
zzzckck merged 1 commit intobnb-chain:developfrom
buddh0:port-db-sync-fix
May 28, 2025
Merged

core, ethdb: introduce database sync function (#31703)#3117
zzzckck merged 1 commit intobnb-chain:developfrom
buddh0:port-db-sync-fix

Conversation

@buddh0
Copy link
Contributor

@buddh0 buddh0 commented May 22, 2025

Description

core, ethdb: introduce database sync function

Rationale

new release v1.5.13 will sync from block 0 after force killed

try to fix this by cherry-picking ethereum/go-ethereum#31703

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

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
@buddh0 buddh0 marked this pull request as ready for review May 23, 2025 08:01
@zzzckck zzzckck requested a review from Copilot May 27, 2025 02:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 zzzckck merged commit a54ffe9 into bnb-chain:develop May 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants