-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Make timeout behavior consistent to document #4134
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
Changes from all commits
8b64ce6
880d848
7196bec
a899554
8c2d10f
8b3c009
b9fe1ef
c9ce123
a510acf
526f708
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import io.druid.java.util.common.guava.Sequence; | ||
| import io.druid.java.util.common.guava.Sequences; | ||
| import io.druid.query.ColumnSelectorPlus; | ||
| import io.druid.query.QueryContexts; | ||
| import io.druid.query.QueryInterruptedException; | ||
| import io.druid.query.dimension.DefaultDimensionSpec; | ||
| import io.druid.query.dimension.DimensionSpec; | ||
|
|
@@ -65,6 +66,7 @@ public Sequence<ScanResultValue> process( | |
| return Sequences.empty(); | ||
| } | ||
| } | ||
| final boolean hasTimeout = QueryContexts.hasTimeout(query); | ||
| final Long timeoutAt = (long) responseContext.get(ScanQueryRunnerFactory.CTX_TIMEOUT_AT); | ||
| final long start = System.currentTimeMillis(); | ||
| final StorageAdapter adapter = segment.asStorageAdapter(); | ||
|
|
@@ -156,7 +158,7 @@ public boolean hasNext() | |
| @Override | ||
| public ScanResultValue next() | ||
| { | ||
| if (System.currentTimeMillis() >= timeoutAt) { | ||
| if (hasTimeout && System.currentTimeMillis() >= timeoutAt) { | ||
| throw new QueryInterruptedException(new TimeoutException()); | ||
| } | ||
| long lastOffset = offset; | ||
|
|
@@ -173,10 +175,12 @@ public ScanResultValue next() | |
| ScanQueryRunnerFactory.CTX_COUNT, | ||
| (long) responseContext.get(ScanQueryRunnerFactory.CTX_COUNT) + (offset - lastOffset) | ||
| ); | ||
| responseContext.put( | ||
| ScanQueryRunnerFactory.CTX_TIMEOUT_AT, | ||
| timeoutAt - (System.currentTimeMillis() - start) | ||
| ); | ||
| if (hasTimeout) { | ||
| responseContext.put( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI #4112
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for letting me know. This behavior looks weird, so I'd like to fix it in this pr if it doesn't require so large change. Since I don't know exactly how the responseContext is supposed to be used, let me make sure what the correct solution is. Is it ok to just move CTX_TIMEOUT_AT to QueryContext instead of ResponseContext?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it's not that easy to fix this, because
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, then I'll look at after this pr. |
||
| ScanQueryRunnerFactory.CTX_TIMEOUT_AT, | ||
| timeoutAt - (System.currentTimeMillis() - start) | ||
| ); | ||
| } | ||
| return new ScanResultValue(segmentId, allColumns, events); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
It still has non-obvious undocumented corner case behaviour if timeoutMs=0, than it waits indefinitely, rather than not waiting at all.
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 don't understand this comment.. If timeoutMs = 0, then take() immediately returns an object or null without waiting at all. Actually, negative
timeoutMss have the same meaning.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.
Yes, my oversight