|
|
@ -84,6 +84,8 @@ type Database struct { |
|
|
|
writeDelayStartTime time.Time // The start time of the latest write stall
|
|
|
|
writeDelayStartTime time.Time // The start time of the latest write stall
|
|
|
|
writeDelayCount atomic.Int64 // Total number of write stall counts
|
|
|
|
writeDelayCount atomic.Int64 // Total number of write stall counts
|
|
|
|
writeDelayTime atomic.Int64 // Total time spent in write stalls
|
|
|
|
writeDelayTime atomic.Int64 // Total time spent in write stalls
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
writeOptions *pebble.WriteOptions |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (d *Database) onCompactionBegin(info pebble.CompactionInfo) { |
|
|
|
func (d *Database) onCompactionBegin(info pebble.CompactionInfo) { |
|
|
@ -118,7 +120,7 @@ func (d *Database) onWriteStallEnd() { |
|
|
|
|
|
|
|
|
|
|
|
// New returns a wrapped pebble DB object. The namespace is the prefix that the
|
|
|
|
// New returns a wrapped pebble DB object. The namespace is the prefix that the
|
|
|
|
// metrics reporting should use for surfacing internal stats.
|
|
|
|
// metrics reporting should use for surfacing internal stats.
|
|
|
|
func New(file string, cache int, handles int, namespace string, readonly bool) (*Database, error) { |
|
|
|
func New(file string, cache int, handles int, namespace string, readonly bool, ephemeral bool) (*Database, error) { |
|
|
|
// Ensure we have some minimal caching and file guarantees
|
|
|
|
// Ensure we have some minimal caching and file guarantees
|
|
|
|
if cache < minCache { |
|
|
|
if cache < minCache { |
|
|
|
cache = minCache |
|
|
|
cache = minCache |
|
|
@ -145,6 +147,7 @@ func New(file string, cache int, handles int, namespace string, readonly bool) ( |
|
|
|
fn: file, |
|
|
|
fn: file, |
|
|
|
log: logger, |
|
|
|
log: logger, |
|
|
|
quitChan: make(chan chan error), |
|
|
|
quitChan: make(chan chan error), |
|
|
|
|
|
|
|
writeOptions: &pebble.WriteOptions{Sync: !ephemeral}, |
|
|
|
} |
|
|
|
} |
|
|
|
opt := &pebble.Options{ |
|
|
|
opt := &pebble.Options{ |
|
|
|
// Pebble has a single combined cache area and the write
|
|
|
|
// Pebble has a single combined cache area and the write
|
|
|
@ -279,7 +282,7 @@ func (d *Database) Put(key []byte, value []byte) error { |
|
|
|
if d.closed { |
|
|
|
if d.closed { |
|
|
|
return pebble.ErrClosed |
|
|
|
return pebble.ErrClosed |
|
|
|
} |
|
|
|
} |
|
|
|
return d.db.Set(key, value, pebble.Sync) |
|
|
|
return d.db.Set(key, value, d.writeOptions) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Delete removes the key from the key-value store.
|
|
|
|
// Delete removes the key from the key-value store.
|
|
|
@ -535,7 +538,7 @@ func (b *batch) Write() error { |
|
|
|
if b.db.closed { |
|
|
|
if b.db.closed { |
|
|
|
return pebble.ErrClosed |
|
|
|
return pebble.ErrClosed |
|
|
|
} |
|
|
|
} |
|
|
|
return b.b.Commit(pebble.Sync) |
|
|
|
return b.b.Commit(b.db.writeOptions) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Reset resets the batch for reuse.
|
|
|
|
// Reset resets the batch for reuse.
|
|
|
|