Skip to content

Commit

Permalink
Fix apply retention issue (#5342)
Browse files Browse the repository at this point in the history
* call mark phase started/finished only when applying retention

* correctly pass userID to IntervalMayHaveExpiredChunks call on retention and dletion expiry check
  • Loading branch information
sandeepsukhani committed Feb 10, 2022
1 parent 20041b7 commit b5c12b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/storage/stores/shipper/compactor/compactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (c *Compactor) CompactTable(ctx context.Context, tableName string, applyRet

interval := retention.ExtractIntervalFromTableName(tableName)
intervalMayHaveExpiredChunks := false
if c.cfg.RetentionEnabled && applyRetention {
if applyRetention {
intervalMayHaveExpiredChunks = c.expirationChecker.IntervalMayHaveExpiredChunks(interval, "")
}

Expand All @@ -424,7 +424,7 @@ func (c *Compactor) RunCompaction(ctx context.Context, applyRetention bool) erro
status := statusSuccess
start := time.Now()

if c.cfg.RetentionEnabled {
if applyRetention {
c.expirationChecker.MarkPhaseStarted()
}

Expand All @@ -439,7 +439,7 @@ func (c *Compactor) RunCompaction(ctx context.Context, applyRetention bool) erro
}
}

if c.cfg.RetentionEnabled {
if applyRetention {
if status == statusSuccess {
c.expirationChecker.MarkPhaseFinished()
} else {
Expand Down Expand Up @@ -550,7 +550,7 @@ func (e *expirationChecker) MarkPhaseFinished() {
}

func (e *expirationChecker) IntervalMayHaveExpiredChunks(interval model.Interval, userID string) bool {
return e.retentionExpiryChecker.IntervalMayHaveExpiredChunks(interval, "") || e.deletionExpiryChecker.IntervalMayHaveExpiredChunks(interval, "")
return e.retentionExpiryChecker.IntervalMayHaveExpiredChunks(interval, userID) || e.deletionExpiryChecker.IntervalMayHaveExpiredChunks(interval, userID)
}

func (e *expirationChecker) DropFromIndex(ref retention.ChunkEntry, tableEndTime model.Time, now model.Time) bool {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/stores/shipper/compactor/compactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCompactor_RunCompaction(t *testing.T) {
cm := storage.NewClientMetrics()
defer cm.Unregister()
compactor := setupTestCompactor(t, tempDir, cm)
err := compactor.RunCompaction(context.Background(), true)
err := compactor.RunCompaction(context.Background(), false)
require.NoError(t, err)

for name := range tables {
Expand Down

0 comments on commit b5c12b5

Please sign in to comment.