-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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 upper limit for scroll expiry #26448
Conversation
This change adds a dynamic cluster setting named `search.max_keep_alive`. It is used as an upper limit for scroll expiry time in scroll queries and defaults to 1 hour. This change also ensures that the existing setting `search.default_keep_alive` is always smaller than `search.max_keep_alive`. Relates elastic#11511
Tests for |
*/ | ||
public synchronized <A, B> void addSettingsUpdateConsumer(Setting<A> a, Setting<B> b, BiConsumer<A, B> consumer) { | ||
addSettingsUpdateConsumer(a, b, consumer, (i, j) -> {} ); | ||
|
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.
remove empty line?
|
||
public void validate(Integer a, Integer b) { | ||
if (Integer.signum(a) != Integer.signum(b)) { | ||
throw new IllegalArgumentException("boom"); |
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 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 expected some reindex integration tests to fail as well.....
/** | ||
* Maximum wait time allowed for throttling. | ||
*/ | ||
private static final long MAX_THROTTLE_WAIT_TIME = TimeUnit.HOURS.toNanos(1); |
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'd probably use a TimeValue
instead. That way you never have to wonder "is this in nanos or millis?"
@@ -189,7 +195,8 @@ public void delayPrepareBulkRequest(ThreadPool threadPool, TimeValue lastBatchSt | |||
|
|||
public TimeValue throttleWaitTime(TimeValue lastBatchStartTime, TimeValue now, int lastBatchSize) { | |||
long earliestNextBatchStartTime = now.nanos() + (long) perfectlyThrottledBatchTime(lastBatchSize); | |||
return timeValueNanos(max(0, earliestNextBatchStartTime - System.nanoTime())); | |||
long waitTime = min(MAX_THROTTLE_WAIT_TIME, max(0, earliestNextBatchStartTime - System.nanoTime())); |
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 like limiting this here but think maybe we ought to also enforce it at request start and rethrottle time. We can work backwards from the batch size to reject requests that had a requests_per_second that is too small, I think.
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 wonder if we should just do that in a followup.
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 think it might be nice to use the actual value of the setting but that can be a "reindex only" followup thing, I think.
Talked to Jim - I was wrong. No tests should fail because we never assert that we wait as long as we say we do. We have an integration test in reindex that starts the request very slow and then rethrottles it to speed it up but one hour is slow enough for it. If we modified reindex to fail user side requests that'd set the limit too long then the test would fail. We probably should do that as a separate change to reindex after this is merged just so no one is surprised about the sleep. |
@@ -189,7 +195,8 @@ public void delayPrepareBulkRequest(ThreadPool threadPool, TimeValue lastBatchSt | |||
|
|||
public TimeValue throttleWaitTime(TimeValue lastBatchStartTime, TimeValue now, int lastBatchSize) { | |||
long earliestNextBatchStartTime = now.nanos() + (long) perfectlyThrottledBatchTime(lastBatchSize); | |||
return timeValueNanos(max(0, earliestNextBatchStartTime - System.nanoTime())); | |||
long waitTime = min(MAX_THROTTLE_WAIT_TIME, max(0, earliestNextBatchStartTime - System.nanoTime())); |
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 think it might be nice to use the actual value of the setting but that can be a "reindex only" followup thing, I think.
This change adds a dynamic cluster setting named `search.max_keep_alive`. It is used as an upper limit for scroll expiry time in scroll queries and defaults to 1 hour. This change also ensures that the existing setting `search.default_keep_alive` is always smaller than `search.max_keep_alive`. Relates #11511 * check style * add skip for bwc * iter * Add a maxium throttle wait time of 1h for reindex * review * remove empty line
Add upper limit for scroll expiry
This change adds a dynamic cluster setting named
search.max_keep_alive
.It is used as an upper limit for scroll expiry time in scroll queries and defaults to 1 day.
For throttling purpose
reindex
overrides the default scroll expiry time automatically and could be affected by this change which is why we use an insanely high default value at the moment (1 day).This change also ensures that the existing setting
search.default_keep_alive
is always smaller thansearch.max_keep_alive
.Relates #11511
Fixes #23268