-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Reuse the same appender for report and scrape #7562
Conversation
1767ce0
to
5133c73
Compare
3aafe11
to
5b10da8
Compare
24d71c4
to
6598956
Compare
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
6598956
to
caa9fbc
Compare
/prombench master |
/prombench cancel |
Benchmark cancel is in progress. |
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
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.
AFAICS, this looks fine. I have only a few nits that don't change how the code is working.
@codesome could you also run a sanity check on this?
Signed-off-by: Julien Pivotto <[email protected]>
Thanks for the review, I have addressed the comments. |
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.
Cool. Now let's get a 👍 from @codesome @krasi-georgiev or @brian-brazil to not merge this without any of the maintainers approving.
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
Signed-off-by: Julien Pivotto <[email protected]>
@beorn7 I added another commit, which makes the end of run staleness consistent. Also now it takes into consideration that Commit() will do a Rollback() if things go mad. |
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 thought you were still working on this, so hadn't reviewed yet.
scrape/scrape_test.go
Outdated
@@ -1928,3 +1970,66 @@ func TestCheckAddError(t *testing.T) { | |||
sl.checkAddError(nil, nil, nil, storage.ErrOutOfOrderSample, nil, &appErrs) | |||
testutil.Equals(t, 1, appErrs.numOutOfOrder) | |||
} | |||
|
|||
func TestScrapeReportIsolation(t *testing.T) { |
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'm not seeing how this is testing isolation, as there's nothing to ensure the query runs between the scrape ingestion and the report ingestion.
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.
Queries run continuously. We should always have a multiple of 9 metrics.
That test is failing almost instantly without the code.
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.
Yes, I was assuming it would happen as @roidelapluie has confirmed now.
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.
The test name is misleading, as this doesn't test anything about isolation per-se. What it's testing is that it's all done in one append.
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.
@roidelapluie that name should be easy to fix.
@brian-brazil is that the only remaining concern in this PR?
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.
Yes, the rest I can live with.
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.
Renamed. I originally named it like this because if the underlying appender does not support isolation, the test failed as well.
scrape/scrape.go
Outdated
} | ||
} | ||
// scrapeAndReport performs a scrape and then appends the result to the storage | ||
// together with reporting metrics, all using the same appender. |
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.
"the same" is a little misleading as a 2nd appender will be created if there's a scrape error.
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.
But in case of a scrape error, the 1st appender is rolled back, so it will not append anything to the storage, so only one and the same appender will ever append any samples to the storage.
But if you have a better suggestion for the wording, I'm sure @roidelapluie will appreciate it.
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.
// scrapeAndReport performs a scrape and then appends the result to the storage
// together with reporting metrics, by using as few appenders as possible.
// In the happy scenario, a single appender is used.
close(sl.stopped) | ||
app := sl.appender() | ||
var err error | ||
defer func() { |
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.
There's no early returns, so I don't see a need to use a defer here compared to putting this code at the end of the function - which would be clearer.
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.
We guard ourselves against potential panic()
Signed-off-by: Julien Pivotto <[email protected]>
Is this good to go @brian-brazil ? Would be great to have this in the release. |
Or in case @brian-brazil is busy, I guess @codesome or @krasi-georgiev are qualified here, too, as it is close to TSDB. |
Signed-off-by: Julien Pivotto <[email protected]>
👍 |
😄 Thanks everyone. |
Fix #6950
Signed-off-by: Julien Pivotto [email protected]