Skip to content

Commit b772c22

Browse files
acuddshulyak
authored andcommitted
swarm/storage: fix influxdb gc metrics report (ethereum#19102)
(cherry picked from commit 5b8ae78)
1 parent f6485fe commit b772c22

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

swarm/storage/ldbstore.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ func decodeData(addr Address, data []byte) (*chunk, error) {
317317
}
318318

319319
func (s *LDBStore) collectGarbage() error {
320-
321320
// prevent duplicate gc from starting when one is already running
322321
select {
323322
case <-s.gc.runC:
@@ -335,7 +334,6 @@ func (s *LDBStore) collectGarbage() error {
335334
s.startGC(int(entryCnt))
336335
log.Debug("collectGarbage", "target", s.gc.target, "entryCnt", entryCnt)
337336

338-
var totalDeleted int
339337
for s.gc.count < s.gc.target {
340338
it := s.db.NewIterator()
341339
ok := it.Seek([]byte{keyGCIdx})
@@ -371,15 +369,15 @@ func (s *LDBStore) collectGarbage() error {
371369
}
372370

373371
s.writeBatch(s.gc.batch, wEntryCnt)
372+
log.Trace("garbage collect batch done", "batch", singleIterationCount, "total", s.gc.count)
374373
s.lock.Unlock()
375374
it.Release()
376-
log.Trace("garbage collect batch done", "batch", singleIterationCount, "total", s.gc.count)
377375
}
378376

379-
s.gc.runC <- struct{}{}
377+
metrics.GetOrRegisterCounter("ldbstore.collectgarbage.delete", nil).Inc(int64(s.gc.count))
380378
log.Debug("garbage collect done", "c", s.gc.count)
379+
s.gc.runC <- struct{}{}
381380

382-
metrics.GetOrRegisterCounter("ldbstore.collectgarbage.delete", nil).Inc(int64(totalDeleted))
383381
return nil
384382
}
385383

0 commit comments

Comments
 (0)