Skip to content

Commit 15bf90e

Browse files
authored
core, ethdb/pebble: run pebble in non-sync mode (ethereum#30573)
Implements ethereum#29819
1 parent a449057 commit 15bf90e

6 files changed

+6
-16
lines changed

core/blockchain_repair_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,6 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
17671767
db, err := rawdb.Open(rawdb.OpenOptions{
17681768
Directory: datadir,
17691769
AncientsDirectory: ancient,
1770-
Ephemeral: true,
17711770
})
17721771
if err != nil {
17731772
t.Fatalf("Failed to create persistent database: %v", err)
@@ -1852,7 +1851,6 @@ func testRepairWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme s
18521851
db, err = rawdb.Open(rawdb.OpenOptions{
18531852
Directory: datadir,
18541853
AncientsDirectory: ancient,
1855-
Ephemeral: true,
18561854
})
18571855
if err != nil {
18581856
t.Fatalf("Failed to reopen persistent database: %v", err)
@@ -1974,7 +1972,6 @@ func testIssue23496(t *testing.T, scheme string) {
19741972
db, err = rawdb.Open(rawdb.OpenOptions{
19751973
Directory: datadir,
19761974
AncientsDirectory: ancient,
1977-
Ephemeral: true,
19781975
})
19791976
if err != nil {
19801977
t.Fatalf("Failed to reopen persistent database: %v", err)

core/blockchain_sethead_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,6 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme
19711971
db, err := rawdb.Open(rawdb.OpenOptions{
19721972
Directory: datadir,
19731973
AncientsDirectory: ancient,
1974-
Ephemeral: true,
19751974
})
19761975
if err != nil {
19771976
t.Fatalf("Failed to create persistent database: %v", err)

core/blockchain_snapshot_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo
6868
db, err := rawdb.Open(rawdb.OpenOptions{
6969
Directory: datadir,
7070
AncientsDirectory: ancient,
71-
Ephemeral: true,
7271
})
7372
if err != nil {
7473
t.Fatalf("Failed to create persistent database: %v", err)
@@ -259,7 +258,6 @@ func (snaptest *crashSnapshotTest) test(t *testing.T) {
259258
newdb, err := rawdb.Open(rawdb.OpenOptions{
260259
Directory: snaptest.datadir,
261260
AncientsDirectory: snaptest.ancient,
262-
Ephemeral: true,
263261
})
264262
if err != nil {
265263
t.Fatalf("Failed to reopen persistent database: %v", err)

core/blockchain_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,6 @@ func testSideImportPrunedBlocks(t *testing.T, scheme string) {
27442744
db, err := rawdb.Open(rawdb.OpenOptions{
27452745
Directory: datadir,
27462746
AncientsDirectory: ancient,
2747-
Ephemeral: true,
27482747
})
27492748
if err != nil {
27502749
t.Fatalf("Failed to create persistent database: %v", err)

core/rawdb/database.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ func NewLevelDBDatabase(file string, cache int, handles int, namespace string, r
319319

320320
// NewPebbleDBDatabase creates a persistent key-value database without a freezer
321321
// moving immutable chain segments into cold storage.
322-
func NewPebbleDBDatabase(file string, cache int, handles int, namespace string, readonly, ephemeral bool) (ethdb.Database, error) {
323-
db, err := pebble.New(file, cache, handles, namespace, readonly, ephemeral)
322+
func NewPebbleDBDatabase(file string, cache int, handles int, namespace string, readonly bool) (ethdb.Database, error) {
323+
db, err := pebble.New(file, cache, handles, namespace, readonly)
324324
if err != nil {
325325
return nil, err
326326
}
@@ -358,9 +358,6 @@ type OpenOptions struct {
358358
Cache int // the capacity(in megabytes) of the data caching
359359
Handles int // number of files to be open simultaneously
360360
ReadOnly bool
361-
// Ephemeral means that filesystem sync operations should be avoided: data integrity in the face of
362-
// a crash is not important. This option should typically be used in tests.
363-
Ephemeral bool
364361
}
365362

366363
// openKeyValueDatabase opens a disk-based key-value database, e.g. leveldb or pebble.
@@ -382,15 +379,15 @@ func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) {
382379
}
383380
if o.Type == dbPebble || existingDb == dbPebble {
384381
log.Info("Using pebble as the backing database")
385-
return NewPebbleDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly, o.Ephemeral)
382+
return NewPebbleDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly)
386383
}
387384
if o.Type == dbLeveldb || existingDb == dbLeveldb {
388385
log.Info("Using leveldb as the backing database")
389386
return NewLevelDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly)
390387
}
391388
// No pre-existing database, no user-requested one either. Default to Pebble.
392389
log.Info("Defaulting to pebble as the backing database")
393-
return NewPebbleDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly, o.Ephemeral)
390+
return NewPebbleDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly)
394391
}
395392

396393
// Open opens both a disk-based key-value database such as leveldb or pebble, but also

ethdb/pebble/pebble.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (l panicLogger) Fatalf(format string, args ...interface{}) {
144144

145145
// New returns a wrapped pebble DB object. The namespace is the prefix that the
146146
// metrics reporting should use for surfacing internal stats.
147-
func New(file string, cache int, handles int, namespace string, readonly bool, ephemeral bool) (*Database, error) {
147+
func New(file string, cache int, handles int, namespace string, readonly bool) (*Database, error) {
148148
// Ensure we have some minimal caching and file guarantees
149149
if cache < minCache {
150150
cache = minCache
@@ -185,7 +185,7 @@ func New(file string, cache int, handles int, namespace string, readonly bool, e
185185
fn: file,
186186
log: logger,
187187
quitChan: make(chan chan error),
188-
writeOptions: &pebble.WriteOptions{Sync: !ephemeral},
188+
writeOptions: &pebble.WriteOptions{Sync: false},
189189
}
190190
opt := &pebble.Options{
191191
// Pebble has a single combined cache area and the write

0 commit comments

Comments
 (0)