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

query-frontend: cancel stream to scheduler when streaming failed #3302

Merged
merged 4 commits into from
Oct 26, 2022

Conversation

dimitarvdimitrov
Copy link
Contributor

@dimitarvdimitrov dimitarvdimitrov commented Oct 25, 2022

Signed-off-by: Dimitar Dimitrov dimitar.dimitrov@grafana.com

What this PR does

discovered by @pstibrany:

makes sure that the query-frontend properly terminates gRPC streams to the query-scheduler after the scheduler closes the connections on them

without this there was a goroutine and memory leak. In the attached screenshot you can see on the left side of each graph GEM running without this fix and on the right side of each graph GEM with this fix.
Screenshot 2022-10-25 at 10 37 01

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg/frontend/v2/frontend_scheduler_worker.go Outdated Show resolved Hide resolved
@dimitarvdimitrov
Copy link
Contributor Author

thanks for the review and the test @pstibrany. I think I've incorporated the changes you requested and the test too. Can you take another look?

Copy link
Member

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

pkg/frontend/v2/frontend_test.go Outdated Show resolved Hide resolved
pkg/frontend/v2/frontend_scheduler_worker.go Outdated Show resolved Hide resolved
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/fix-query-frontend-grpc-stream-closure branch from 6e8b971 to 8076883 Compare October 26, 2022 08:07
dimitarvdimitrov and others added 2 commits October 26, 2022 10:08
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
@dimitarvdimitrov dimitarvdimitrov force-pushed the dimitar/fix-query-frontend-grpc-stream-closure branch from 8076883 to 362838c Compare October 26, 2022 08:09
@pracucci pracucci self-requested a review October 26, 2022 09:44
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! I just let a nit 🙏

require.Equal(t, 1, checkStreamGoroutines())
}

const createdBy = "created by google.golang.org/grpc.newClientStreamWithParams"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Move this const inside checkStreamGoroutines().

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
@pracucci pracucci enabled auto-merge (squash) October 26, 2022 10:11
@pracucci pracucci merged commit 2c25bb0 into main Oct 26, 2022
@pracucci pracucci deleted the dimitar/fix-query-frontend-grpc-stream-closure branch October 26, 2022 10:23
masonmei pushed a commit to udmire/mimir that referenced this pull request Nov 4, 2022
…fana#3302)

* query-frontend: cancel stream to scheduler when streaming failed

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>

* Add changelog entry

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>

* Add test for proper stream cleanup

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>

* Simplify checkStreamGoroutines

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
masonmei pushed a commit to udmire/mimir that referenced this pull request Nov 4, 2022
…fana#3302)

* query-frontend: cancel stream to scheduler when streaming failed

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>

* Add changelog entry

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>

* Add test for proper stream cleanup

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>

* Simplify checkStreamGoroutines

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Co-authored-by: Peter Štibraný <pstibrany@gmail.com>
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.

None yet

3 participants