Skip to content

Commit

Permalink
Don't prune slabs on startup (#1772)
Browse files Browse the repository at this point in the history
If the database is busy due to lots of slabs requiring pruning, this can
prevent renterd from starting. Instead the background loop should handle
this.

Ran this on gompa to get it to break out of a restart loop
  • Loading branch information
n8maninger authored Jan 3, 2025
2 parents ea6447f + 3aeccca commit 5b6f026
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/dont_perform_full_slab_prune_on_startup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

# don't perform full slab prune on startup
13 changes: 2 additions & 11 deletions stores/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package stores
import (
"context"
"fmt"
"math"
"os"
"sync"
"time"
Expand Down Expand Up @@ -110,25 +109,17 @@ func NewSQLStore(cfg Config) (*SQLStore, error) {
if err != nil {
return nil, err
}
if err := ss.initSlabPruning(); err != nil {
return nil, err
}
ss.initSlabPruning()
return ss, nil
}

func (s *SQLStore) initSlabPruning() error {
func (s *SQLStore) initSlabPruning() {
// start pruning loop
s.wg.Add(1)
go func() {
s.pruneSlabsLoop()
s.wg.Done()
}()

// prune once to guarantee consistency on startup
return s.db.Transaction(s.shutdownCtx, func(tx sql.DatabaseTx) error {
_, err := tx.PruneSlabs(s.shutdownCtx, math.MaxInt64)
return err
})
}

// Close closes the underlying database connection of the store.
Expand Down

0 comments on commit 5b6f026

Please sign in to comment.