Skip to content

Commit

Permalink
reset leveldb batch after the commit
Browse files Browse the repository at this point in the history
While committing data to leveldb in iteration, it is
necessary to reset the batch. Otherwise, we would be
appending entries and rewriting written entries in the
previous iteration.

Signed-off-by: Senthil Nathan N <cendhu@gmail.com>
  • Loading branch information
cendhu authored and ale-linux committed Sep 8, 2020
1 parent bebe131 commit 20f0697
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/ledger/pvtdatastorage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@ func (s *Store) purgeExpiredData(minBlkNum, maxBlkNum uint64) error {
batch.Delete(encodeMissingDataKey(missingDataKey))
}
s.db.WriteBatch(batch, false)
batch.Reset()
}
logger.Infof("[%s] - [%d] Entries purged from private data storage till block number [%d]", s.ledgerid, len(expiryEntries), maxBlkNum)
return nil
Expand Down Expand Up @@ -870,7 +871,7 @@ func (s *Store) processCollElgEvents() error {
collEntriesConverted++
if batch.Len() > s.maxBatchSize {
s.db.WriteBatch(batch, true)
batch = s.db.NewUpdateBatch()
batch.Reset()
sleepTime := time.Duration(s.batchesInterval)
logger.Infof("Going to sleep for %d milliseconds between batches. Entries for [ns=%s, coll=%s] converted so far = %d",
sleepTime, ns, coll, collEntriesConverted)
Expand Down

0 comments on commit 20f0697

Please sign in to comment.