diff --git a/storage/localstore/gc.go b/storage/localstore/gc.go index 6373ecc7d7..6433c0c45d 100644 --- a/storage/localstore/gc.go +++ b/storage/localstore/gc.go @@ -183,7 +183,6 @@ func (db *DB) removeChunksInExcludeIndexFromGC() (err error) { gcSizeChange-- } excludedCount++ - db.gcExcludeIndex.DeleteInBatch(batch, item) } return false, nil diff --git a/storage/localstore/mode_set.go b/storage/localstore/mode_set.go index 319ec1bf87..26f576ae10 100644 --- a/storage/localstore/mode_set.go +++ b/storage/localstore/mode_set.go @@ -374,6 +374,7 @@ func (db *DB) setPin(batch *leveldb.Batch, addr chunk.Address) (err error) { // setUnpin decrements pin counter for the chunk by updating pin index. // Provided batch is updated. func (db *DB) setUnpin(batch *leveldb.Batch, addr chunk.Address) (err error) { + metricName := "localstore/gc/exclude" item := addressToItem(addr) // Get the existing pin counter of the chunk @@ -389,6 +390,8 @@ func (db *DB) setUnpin(batch *leveldb.Batch, addr chunk.Address) (err error) { db.pinIndex.PutInBatch(batch, item) } else { db.pinIndex.DeleteInBatch(batch, item) + db.gcExcludeIndex.DeleteInBatch(batch, item) + metrics.GetOrRegisterCounter(metricName+"/excluded-count", nil).Dec(int64(1)) } return nil