Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion storage/localstore/localstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,6 @@ func TestDBDebugIndexes(t *testing.T) {
}

// assert that there's a pin and gc exclude entry now
testIndexCounts(t, 1, 1, 1, 1, 1, 1, 1, indexCounts)
testIndexCounts(t, 1, 1, 0, 1, 1, 1, 1, indexCounts)

}
11 changes: 10 additions & 1 deletion storage/localstore/mode_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ func (db *DB) updateGC(item shed.Item) (err error) {
// update retrieve access index
db.retrievalAccessIndex.PutInBatch(batch, item)
// add new entry to gc index
db.gcIndex.PutInBatch(batch, item)
ok, err := db.pinIndex.Has(item)
if err != nil {
return err
}
if !ok {
err = db.gcIndex.PutInBatch(batch, item)
if err != nil {
return err
}
}

return db.shed.WriteBatch(batch)
}
Expand Down
13 changes: 11 additions & 2 deletions storage/localstore/mode_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,17 @@ func (db *DB) setGC(batch *leveldb.Batch, item shed.Item) (gcSizeChange int64, e
item.AccessTimestamp = now()
db.retrievalAccessIndex.PutInBatch(batch, item)

db.gcIndex.PutInBatch(batch, item)
gcSizeChange++
ok, err := db.pinIndex.Has(item)
if err != nil {
return 0, err
}
if !ok {
err = db.gcIndex.PutInBatch(batch, item)
if err != nil {
return 0, err
}
gcSizeChange++
}

return gcSizeChange, nil
}
Expand Down
19 changes: 16 additions & 3 deletions storage/localstore/mode_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,18 @@ func (db *DB) setAccess(batch *leveldb.Batch, binIDs map[uint8]uint64, addr chun
item.AccessTimestamp = now()
db.retrievalAccessIndex.PutInBatch(batch, item)
db.pullIndex.PutInBatch(batch, item)
db.gcIndex.PutInBatch(batch, item)
gcSizeChange++

ok, err := db.pinIndex.Has(item)
if err != nil {
return 0, err
}
if !ok {
err = db.gcIndex.PutInBatch(batch, item)
if err != nil {
return 0, err
}
gcSizeChange++
}

return gcSizeChange, nil
}
Expand Down Expand Up @@ -296,7 +306,10 @@ func (db *DB) setSync(batch *leveldb.Batch, addr chunk.Address, mode chunk.ModeS
return 0, err
}
if !ok {
db.gcIndex.PutInBatch(batch, item)
err = db.gcIndex.PutInBatch(batch, item)
if err != nil {
return 0, err
}
gcSizeChange++
}

Expand Down