Skip to content

Commit

Permalink
stores: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Apr 4, 2024
1 parent 98626ba commit 56adf02
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,7 @@ func (s *SQLStore) pruneSlabsLoop() {
return
}

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second+sumDurations(s.retryTransactionIntervals))
err := s.retryTransaction(ctx, pruneSlabs)
if err != nil {
s.logger.Errorw("failed to prune slabs", zap.Error(err))
Expand Down
3 changes: 0 additions & 3 deletions stores/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4097,7 +4097,6 @@ func TestSlabCleanup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)

// check slice count
var slabCntr int64
Expand All @@ -4115,7 +4114,6 @@ func TestSlabCleanup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)

ss.Retry(100, 100*time.Millisecond, func() error {
if err := ss.db.Model(&dbSlab{}).Count(&slabCntr).Error; err != nil {
Expand Down Expand Up @@ -4164,7 +4162,6 @@ func TestSlabCleanup(t *testing.T) {
if err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)

ss.Retry(100, 100*time.Millisecond, func() error {
if err := ss.db.Model(&dbSlab{}).Count(&slabCntr).Error; err != nil {
Expand Down
10 changes: 8 additions & 2 deletions stores/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ func NewSQLStore(cfg Config) (*SQLStore, modules.ConsensusChangeID, error) {
}

shutdownCtx, shutdownCtxCancel := context.WithCancel(context.Background())
slabPruneOngoing := make(chan struct{})
close(slabPruneOngoing)
ss := &SQLStore{
alerts: cfg.Alerts,
db: db,
Expand Down Expand Up @@ -622,3 +620,11 @@ func (s *SQLStore) ResetConsensusSubscription(ctx context.Context) error {
s.persistMu.Unlock()
return nil
}

func sumDurations(durations []time.Duration) time.Duration {
var sum time.Duration
for _, d := range durations {
sum += d
}
return sum
}

0 comments on commit 56adf02

Please sign in to comment.