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

Add RequireNoWait header #3502

Merged
merged 12 commits into from
May 18, 2021
Merged

Add RequireNoWait header #3502

merged 12 commits into from
May 18, 2021

Conversation

rallen090
Copy link
Collaborator

@rallen090 rallen090 commented May 17, 2021

What this PR does / why we need it:

Add optional header to require that permits will never wait.

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


Copy link
Collaborator

@arnikola arnikola left a comment

Choose a reason for hiding this comment

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

LGTM with a couple of nits, but you may want someone more familiar with these paths have a look 👍

@@ -244,6 +244,7 @@ func FromRPCFetchTaggedRequest(
StartInclusive: start,
EndExclusive: end,
RequireExhaustive: req.RequireExhaustive,
RequireNoWait: req.RequireNoWait,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we get some tests for FromRPCFetchTaggedRequest->ToRPCFetchTaggedRequest and back cases to verify we don't drop these params? Same with the other convert func

Copy link
Collaborator

Choose a reason for hiding this comment

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

There's an integration test thankfully here, but agreed unit tests should also be added.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Added unit test.

@@ -37,13 +37,16 @@ func TestFixedPermits(t *testing.T) {
require.NoError(t, err)
expectedP := NewPermit(1, iOpts)
expectedP.(*permit).refCount.Inc()
p, err := fp.Acquire(ctx)
r, err := fp.Acquire(ctx)
p := r.Permit
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: check error first in case this is nil, same for the other calls in this file

Copy link
Collaborator

Choose a reason for hiding this comment

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

Done.

@@ -104,6 +104,10 @@ const (
// ensure M3 returns an error if the results set is not exhaustive.
LimitRequireExhaustiveHeader = M3HeaderPrefix + "Limit-Require-Exhaustive"

// LimitRequireNoWaitHeader is the M3 header that ensures
// M3 returns an error if query execution must wait for permits.
LimitRequireNoWaitHeader = M3HeaderPrefix + "Limit-Require-NoWait"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Limit-Require-No-Wait to keep consistency?

return v, nil
}

if str := req.FormValue("requireNoWait"); str != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: const this out?

WaitedSeriesRead int `json:"waitedSeriesRead"`
}

// Any returns whether any waiting occurred.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe Waited has a little more context?

@@ -58,6 +67,15 @@ type Permits interface {
Release(permit Permit)
}

// AcquireResult contains metadata about acquiring a permit.
Copy link
Collaborator

Choose a reason for hiding this comment

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

meganit: not quite metadata since it contains the permit itself

@robskillington robskillington enabled auto-merge (squash) May 18, 2021 10:54
@robskillington robskillington merged commit 1bbff71 into master May 18, 2021
@robskillington robskillington deleted the ra/require-no-wait-header branch May 18, 2021 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants