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

Reuse the same appender for report and scrape #7562

Merged
merged 13 commits into from
Jul 16, 2020

Conversation

roidelapluie
Copy link
Member

@roidelapluie roidelapluie commented Jul 11, 2020

Fix #6950

Signed-off-by: Julien Pivotto [email protected]

@roidelapluie roidelapluie changed the title Scrape tests: implement isolation in collectResultAppender Reuse the same appender for report and scrape Jul 12, 2020
@roidelapluie roidelapluie force-pushed the isolation-test branch 3 times, most recently from 24d71c4 to 6598956 Compare July 12, 2020 19:16
@roidelapluie
Copy link
Member Author

/prombench master

@prombot
Copy link
Contributor

prombot commented Jul 12, 2020

⏱️ Welcome to Prometheus Benchmarking Tool. ⏱️

Compared versions: PR-7562 and master

After successful deployment, the benchmarking metrics can be viewed at:

Other Commands:
To stop benchmark: /prombench cancel
To restart benchmark: /prombench restart master

@roidelapluie
Copy link
Member Author

/prombench cancel

@prombot
Copy link
Contributor

prombot commented Jul 13, 2020

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]>
Copy link
Member

@beorn7 beorn7 left a 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?

scrape/helpers_test.go Outdated Show resolved Hide resolved
scrape/helpers_test.go Outdated Show resolved Hide resolved
scrape/scrape.go Outdated Show resolved Hide resolved
scrape/scrape.go Outdated Show resolved Hide resolved
Signed-off-by: Julien Pivotto <[email protected]>
@roidelapluie
Copy link
Member Author

Thanks for the review, I have addressed the comments.

Copy link
Member

@beorn7 beorn7 left a 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]>
@roidelapluie
Copy link
Member Author

@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.

Copy link
Contributor

@brian-brazil brian-brazil left a 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.

@@ -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) {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member Author

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.
Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Member Author

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() {
Copy link
Contributor

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.

Copy link
Member Author

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]>
@beorn7
Copy link
Member

beorn7 commented Jul 16, 2020

Is this good to go @brian-brazil ? Would be great to have this in the release.

@beorn7 beorn7 mentioned this pull request Jul 16, 2020
@beorn7
Copy link
Member

beorn7 commented Jul 16, 2020

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]>
@brian-brazil
Copy link
Contributor

👍

@roidelapluie roidelapluie merged commit 754461b into prometheus:master Jul 16, 2020
@beorn7
Copy link
Member

beorn7 commented Jul 16, 2020

😄 Thanks everyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ingestion: Use the same appender for regular samples and reporting (up and friends)
4 participants