Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not consider out-of-order blocks when filtering compactable jobs #7342

Merged
merged 2 commits into from
Feb 12, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
* [BUGFIX] Query-frontend: fix race condition when sharding active series is enabled (see above) and response is compressed with snappy. #7290
* [BUGFIX] Query-frontend: "query stats" log unsuccessful replies from downstream as "failed". #7296
* [BUGFIX] Packaging: remove reload from systemd file as mimir does not take into account SIGHUP. #7345
* [BUGFIX] Compactor: do not allow out-of-order blocks to prevent timely compaction. #7342

### Mixin

Expand Down
8 changes: 6 additions & 2 deletions pkg/compactor/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,15 @@ func jobWaitPeriodElapsed(ctx context.Context, job *Job, waitPeriod time.Duratio
return true, nil, nil
}

// Check if the job contains any source block uploaded more recently
// than "wait period" ago.
// Check if the job contains any source block uploaded more recently than "wait period" ago,
// ignoring out of order blocks.
threshold := time.Now().Add(-waitPeriod)

for _, meta := range job.Metas() {
if meta.OutOfOrder || meta.Compaction.FromOutOfOrder() {
continue
}

metaPath := path.Join(meta.ULID.String(), block.MetaFilename)

attrs, err := userBucket.Attributes(ctx, metaPath)
Expand Down
15 changes: 15 additions & 0 deletions pkg/compactor/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ func TestJobWaitPeriodElapsed(t *testing.T) {
meta3 := &block.Meta{BlockMeta: tsdb.BlockMeta{ULID: ulid.MustNew(3, nil), Compaction: tsdb.BlockMetaCompaction{Level: 2}}}
meta4 := &block.Meta{BlockMeta: tsdb.BlockMeta{ULID: ulid.MustNew(4, nil), Compaction: tsdb.BlockMetaCompaction{Level: 2}}}

// OOO blocks
meta5 := &block.Meta{BlockMeta: tsdb.BlockMeta{ULID: ulid.MustNew(5, nil), Compaction: tsdb.BlockMetaCompaction{Level: 1}}}
meta6 := &block.Meta{BlockMeta: tsdb.BlockMeta{ULID: ulid.MustNew(6, nil), Compaction: tsdb.BlockMetaCompaction{Level: 1}}}
meta5.Compaction.SetOutOfOrder()
meta6.Compaction.SetOutOfOrder()

tests := map[string]struct {
waitPeriod time.Duration
jobBlocks []jobBlock
Expand Down Expand Up @@ -90,6 +96,15 @@ func TestJobWaitPeriodElapsed(t *testing.T) {
expectedElapsed: true,
expectedMeta: nil,
},
"out of order block": {
waitPeriod: 10 * time.Minute,
jobBlocks: []jobBlock{
{meta: meta5, attrs: objstore.ObjectAttributes{LastModified: time.Now().Add(-20 * time.Minute)}},
{meta: meta6, attrs: objstore.ObjectAttributes{LastModified: time.Now().Add(-5 * time.Minute)}},
},
expectedElapsed: true,
expectedMeta: nil,
},
"an error occurred while checking the blocks upload timestamp": {
waitPeriod: 10 * time.Minute,
jobBlocks: []jobBlock{
Expand Down