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

distributor: check for inflight bytes before reading httpgrpc message without message size in metadata. #6534

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pstibrany
Copy link
Member

What this PR does

This is enhancement of #6300, this PR rejects push requests coming from httpgrpc if Distributor is already at inflight-bytes limit. Previously this check would be skipped if gRPC message did not pass request size.

This was pointed out for ingesters in #6492 (comment), and distributors had the same bug.

Checklist

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

@pstibrany pstibrany requested a review from a team as a code owner November 1, 2023 16:31
@leizor
Copy link
Contributor

leizor commented Nov 28, 2023

The CHANGELOG has just been cut to prepare for the next Mimir release. Please rebase main and eventually move the CHANGELOG entry added / updated in this PR to the top of the CHANGELOG document. Thanks!

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.

Thanks Peter for reviving this PR! I left a question.

}

func (d *Distributor) checkInflightBytes(inflightBytes int64) error {
func (d *Distributor) checkInflightBytes(inflightBytes int64, rejectEqualInflightBytes bool) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The rejectEqualInflightBytes looks a complication with a minimal benefit. I don't think we need a limit which is precise at the byte, but just good enough. Can we just remove 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.

Fair enough, I've simplified it in distributor.

Ingester has similar check, and I quickly tried to remove it too, but then tests got more complicated, so I left it as-is.

@@ -1109,17 +1118,6 @@ func (d *Distributor) startPushRequest(ctx context.Context, httpgrpcRequestSize
return ctx, rs, nil
}

func (d *Distributor) checkHttpgrpcRequestSize(rs *requestState, httpgrpcRequestSize int64) error {
// If httpgrpcRequestSize was already checked, don't check it again.
if rs.httpgrpcRequestSize > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check has been lost. Why it's not required anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm sorry. I'm still lost. The check here was on rs.httpgrpcRequestSize to avoid double adding the size of 1 request to the accumulater. The check done in the line you linked is not on rs.httpgrpcRequestSize.

Copy link
Member Author

@pstibrany pstibrany Jan 22, 2024

Choose a reason for hiding this comment

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

I see what you mean now. This check is in fact unnecessary. We only pass valid httpgrpcRequestSize from public StartPushRequest, which is called exactly once from gRPC handler. So we can't possibly try to check different httpgrpc sizes for the same request.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see what you mean and you're right. I think the check if rs.httpgrpcRequestSize > 0 was introduced to make the code safer against possible future changes. Given it's an extra if condition doesn't look a bad idea to keep it to me (given how tricky is the wiring here) but I also don't feel strong about it.

…known.

Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
Signed-off-by: Peter Štibraný <pstibrany@gmail.com>
@pstibrany pstibrany force-pushed the check-inflight-bytes-limit-for-unknown-sizes branch from f08cf5f to df67c58 Compare January 22, 2024 08:35
@@ -1109,17 +1118,6 @@ func (d *Distributor) startPushRequest(ctx context.Context, httpgrpcRequestSize
return ctx, rs, nil
}

func (d *Distributor) checkHttpgrpcRequestSize(rs *requestState, httpgrpcRequestSize int64) error {
// If httpgrpcRequestSize was already checked, don't check it again.
if rs.httpgrpcRequestSize > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I see what you mean and you're right. I think the check if rs.httpgrpcRequestSize > 0 was introduced to make the code safer against possible future changes. Given it's an extra if condition doesn't look a bad idea to keep it to me (given how tricky is the wiring here) but I also don't feel strong about it.

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.

3 participants