Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
weiihann committed Oct 2, 2024
1 parent af82268 commit 22dc7b9
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions db/pebble/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ func (b *batch) Discard() error {

// Commit : see db.Transaction.Commit
func (b *batch) Commit() error {
start := time.Now()
defer func() { b.listener.OnCommit(time.Since(start)) }()

if b.batch == nil {
return ErrDiscardedTransaction
}

start := time.Now()
defer func() { b.listener.OnCommit(time.Since(start)) }()
return utils.RunAndWrapOnError(b.Discard, b.batch.Commit(pebble.Sync))
}

Expand All @@ -70,13 +69,13 @@ func (b *batch) Set(key, val []byte) error {

// Delete : see db.Transaction.Delete
func (b *batch) Delete(key []byte) error {
start := time.Now()
defer func() { b.listener.OnIO(true, time.Since(start)) }()

if b.batch == nil {
return ErrDiscardedTransaction

Check warning on line 73 in db/pebble/batch.go

View check run for this annotation

Codecov / codecov/patch

db/pebble/batch.go#L73

Added line #L73 was not covered by tests
}

start := time.Now()
defer func() { b.listener.OnIO(true, time.Since(start)) }()

return b.batch.Delete(key, pebble.Sync)
}

Expand Down

0 comments on commit 22dc7b9

Please sign in to comment.