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

TSDB: Add time series aggs cancellation #83492

Merged
merged 11 commits into from
Feb 15, 2022

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Feb 4, 2022

Adds support for low-level cancelling time-series based aggregations before
they reach the reduce phase.

Relates to #74660

Adds support for low-level cancelling time-series based aggregations before
they reach the reduce phase.

Relates to elastic#74660
@imotov imotov requested review from romseygeek and nik9000 February 8, 2022 00:09
@imotov imotov marked this pull request as ready for review February 8, 2022 00:09
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Feb 8, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)


@Override
public int nextDoc() throws IOException {
checkCancelled.run();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to run cancellation checks on every single move of the iterator or would it be better to do some sampling here? This could get very expensive.

@imotov imotov requested a review from romseygeek February 10, 2022 04:43
Copy link
Contributor

@romseygeek romseygeek 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 in general, I left a couple of comments around the scorer and weight implementations.

return new Weight(weight.getQuery()) {
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
throw new UnsupportedOperationException();
Copy link
Contributor

Choose a reason for hiding this comment

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

Delegate to weight.explain(context, doc) here?


@Override
public boolean isCacheable(LeafReaderContext ctx) {
throw new UnsupportedOperationException();
Copy link
Contributor

Choose a reason for hiding this comment

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

And delegate here too

* The main purpose of this class is to allow cancellation of search requests. Note that this class doesn't wrap bulk scorer, for that
* use {@link CancellableBulkScorer} instead.
*/
public class CancellableScorer extends Scorer {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could extend FilterScorer here which would simplify things a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that was my first attempt, but it wasn't possible due to some methods being final. But it is a really sensible suggestion, so I think I should probably add a comment explaining all this.

@imotov
Copy link
Contributor Author

imotov commented Feb 10, 2022

@elasticmachine update branch

@imotov
Copy link
Contributor Author

imotov commented Feb 11, 2022

@elasticmachine update branch

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I think it'd be kind of nice to have a unit test that can assert that there are multiple segments. Not that it is a better test than the integration test, but it could catch some odd cases years from now when your integration test doesn't notice that it is running against a single segment due to, well, who knows what. I'm coming at this from pure paranoia. Mostly because I might make some crazy change years from now that invalidates the test and we never know it.

.setSource("@timestamp", now + (long) i * numberOfDocsPerRefresh + j, "val", (double) j, "dim", String.valueOf(i))
);
}
assertNoFailures(bulkRequestBuilder.get());
Copy link
Member

Choose a reason for hiding this comment

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

This won't really "make sure" we have a few segments - just make it quite likely. I'm guessing if you were to run an index stats after this to confirm we had a few segments it'd fail some percent of the time. Its fine, I think, but maybe comment is optimistic.

@@ -483,7 +604,9 @@ private Object blockScript(Map<String, Object> params) {
if (runnable != null) {
runnable.run();
}
LogManager.getLogger(SearchCancellationIT.class).info("Blocking in reduce");
if (shouldBlock.get()) {
LogManager.getLogger(SearchCancellationIT.class).info("Blocking in reduce");
Copy link
Member

Choose a reason for hiding this comment

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

Let's just declare a private static final Logger logger = LogManager.getLogger()?

@nik9000
Copy link
Member

nik9000 commented Feb 14, 2022

maybe remove WIP label.

@imotov imotov removed the WIP label Feb 14, 2022
@imotov
Copy link
Contributor Author

imotov commented Feb 15, 2022

@elasticmachine run elasticsearch-ci/part-2

@imotov
Copy link
Contributor Author

imotov commented Feb 15, 2022

@elasticmachine update branch

@imotov imotov merged commit a89d4c3 into elastic:master Feb 15, 2022
weizijun added a commit to weizijun/elasticsearch that referenced this pull request Feb 16, 2022
…ijun/elasticsearch into fix-none-tsdb-index-dimension-tests

* 'fix-none-tsdb-index-dimension-tests' of github.com:weizijun/elasticsearch: (37 commits)
  [docs] Mention JDK 17 in the Contributing docs (elastic#84018)
  Fix GeoIpDownloader startup during rolling upgrade (elastic#84000)
  Script: Fields API for Dense Vector (elastic#83550)
  Move InferenceConfigUpdate under VersionedNamedWriteable (elastic#84022)
  [ML] Fix license feature test cleanup (elastic#84020)
  Replace deprecated api in artifact transforms (elastic#84015)
  QL: Add leniency option to SQL CLI (elastic#83795)
  [Stack Monitoring] add kibana_stats version alias to -mb template (elastic#83930)
  Optimize spliterator for ImmutableOpenMap (elastic#83899)
  Feature usage actions for archive (elastic#83931)
  Use latch to speedup multi feature migration test (elastic#84007)
  Make action names available in NodeClient (elastic#83919)
  [DOCS] Re-add HTTP proxy setings from elastic#82737 (elastic#84001)
  Add CI matrix configuration for snapshot BWC versions (elastic#83990)
  Update YAML Rest tests to check for product header on all responses (elastic#83290)
  TSDB: Add time series aggs cancellation (elastic#83492)
  [DOCS] Fix percolate query headings (elastic#83988)
  [DOCS] Move tip for percolate query example (elastic#83972)
  Simplify LocalExporter cleaner function to fix failing tests (elastic#83812)
  [GCE Discovery] Correcly handle large zones with 500 or more instances (elastic#83785)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :StorageEngine/TSDB You know, for Metrics Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants