Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-goswami committed Oct 14, 2019
1 parent 12cea56 commit 054ac4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1700,7 +1700,11 @@ func (vlog *valueLog) flushDiscardStats() {
}

if vlog.lfDiscardStats.updatesSinceFlush > discardStatsFlushThreshold {
encodedDS, _ = json.Marshal(vlog.lfDiscardStats.m)
var err error
encodedDS, err = json.Marshal(vlog.lfDiscardStats.m)
if err != nil {
return
}
vlog.lfDiscardStats.updatesSinceFlush = 0
}
return
Expand Down
6 changes: 3 additions & 3 deletions value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ func TestPersistLFDiscardStats(t *testing.T) {
db.vlog.lfDiscardStats.Unlock()

// db.vlog.lfDiscardStats.updatesSinceFlush is already > discardStatsFlushThreshold,
// send empty map to flushChan, so that latest discardStats map can be persited.
// send empty map to flushChan, so that latest discardStats map can be persisted.
db.vlog.lfDiscardStats.flushChan <- map[uint32]int64{}
time.Sleep(1 * time.Second) // Wait to map to be persisted.
time.Sleep(1 * time.Second) // Wait for map to be persisted.
err = db.Close()
require.NoError(t, err)

Expand Down Expand Up @@ -1000,7 +1000,7 @@ func TestValueLogTruncate(t *testing.T) {
require.NoError(t, db.Close())
}

// // Regression test for https://github.com/dgraph-io/dgraph/issues/3669
// Regression test for https://github.com/dgraph-io/dgraph/issues/3669
func TestTruncatedDiscardStat(t *testing.T) {
dir, err := ioutil.TempDir("", "badger-test")
require.NoError(t, err)
Expand Down

0 comments on commit 054ac4e

Please sign in to comment.