From ca5e4b4165bc9cee473ee2da868eb5e4db6906fa Mon Sep 17 00:00:00 2001 From: santicomp2014 Date: Thu, 21 May 2020 21:53:06 -0300 Subject: [PATCH] storage/localstore: moved gcExcludeIndex.DeleteBatch from removeChunksInExcludeIndexFromGC to setUnpin --- storage/localstore/gc.go | 1 - storage/localstore/mode_set.go | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) 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