-
Notifications
You must be signed in to change notification settings - Fork 529
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
Add -compactor.first-level-compaction-wait-period support #4401
Conversation
@@ -673,15 +675,15 @@ func (c *MultitenantCompactor) compactUserWithRetries(ctx context.Context, userI | |||
} | |||
|
|||
func (c *MultitenantCompactor) compactUser(ctx context.Context, userID string) error { | |||
bucket := bucket.NewUserBucketClient(userID, c.bucketClient, c.cfgProvider) | |||
userBucket := bucket.NewUserBucketClient(userID, c.bucketClient, c.cfgProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: renamed just to clarify it's the "user bucket".
reg := prometheus.NewRegistry() | ||
defer c.syncerMetrics.gatherThanosSyncerMetrics(reg) | ||
|
||
ulogger := util_log.WithUserID(userID, c.logger) | ||
userLogger := util_log.WithUserID(userID, c.logger) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: renamed just to clarify it's the "user logger".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some non-blocking feedback.
pkg/compactor/job_wait_period.go
Outdated
return true, nil | ||
} | ||
|
||
if ok, err := jobContainsBlocksUploadedAfter(ctx, job, userBucket, time.Now().Add(-waitPeriod)); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe it makes sense to pass time.Now()
as an argument to avoid calling it in a loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly don't think will make any visible difference. We're not calling it millions of times.
pkg/compactor/compactor_test.go
Outdated
// We expect only 1 compaction job has been expected, while the 2nd has been skipped. | ||
tsdbPlanner.AssertNumberOfCalls(t, "Plan", 1) | ||
|
||
assert.ElementsMatch(t, []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this isn't the first test to do this, but I really don't like asserting on side effects of an operation (info
log statements) instead of the results (some sort of "compaction result" object?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point. I've simplified it in 6e8f723. I'm still checking logs, but asserting only on 1 log line, which is what we care about in this test.
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
fb7a88c
to
04a98e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, left some minor comments. Happy to see this option!
pkg/compactor/compactor_test.go
Outdated
|
||
// Mock two tenants, each with the same exact overlapping blocks. However, | ||
// the 2nd tenant has uploaded the blocks less than "wait period" ago. | ||
bucketClient := &bucket.ClientMock{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Could we use a real bucket instead? (inmem or filesystem) These "mocks" create brittle tests that are tightly coupled with the implementation (eg. we need to provide response for deletion-mark.json or no-compact-mark.json files, even if they are not important for this test at all).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done in 6e8f723.
pkg/compactor/compactor_test.go
Outdated
// We expect only 1 compaction job has been expected, while the 2nd has been skipped. | ||
tsdbPlanner.AssertNumberOfCalls(t, "Plan", 1) | ||
|
||
assert.ElementsMatch(t, []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of matching all elements, we should only check for message that's relevant for this test, to avoid creating very fragile test that needs changes on every log message change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 6e8f723.
Signed-off-by: Marco Pracucci <marco@pracucci.com>
…tLevelCompactionBlocksAndWaitPeriodNotElapsed to use a real bucket client and only assert on a specific log message Signed-off-by: Marco Pracucci <marco@pracucci.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my feedback.
What this PR does
In this PR I proposed to introduce
compactor.first-level-compaction-wait-period
configuration option to address the issue described by #4365.Notes:
Which issue(s) this PR fixes or relates to
Part of #4365
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]