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 lane enforcement for joinish queries #9563

Merged
merged 5 commits into from
Mar 30, 2020

Conversation

clintropolis
Copy link
Member

@clintropolis clintropolis commented Mar 25, 2020

Description

This PR partially squares up the joins work of #9503, #9533, and #9545 with the query laning added in #9407, by extending lane enforcement to queries that run with the LocalQuerySegmentWalker of ClientQuerySegmentWalker, fixing a bug that queries that only use the LocalQuerySegmentWalker are not counted at all. This PR puts things into an interim state so that these queries can fall under lane enforcement, but it has a flaw that it will sequentially acquire and release lanes for each time the ClientQuerySegmentWalker invokes either its local or cluster walker to run a part of a query rather than acquiring all necessary lanes up front and holding through the duration of the query. This is not really an ideal state, since it opens the possibility to fail midway through if a query loses a lane to another query, but it is better than not counting them, and so worth doing for the short term I think.

Ideally, we could bring up the call to QueryScheduler.run into ClientQuerySegmentWalker or even the http resources, but this isn't currently possible without a fairly heavy refactor of how the broker runs queries. This is due to how they are transformed on the way down, where QueryScheduler.prioritizeAndLaneQuery happens on in the deepest part of the cluster and local walkers runners right before they call QueryScheduler.run because that is when the segments participating in the query are available. I'm not quite sure what this will look like yet.


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths.
  • added integration tests.
  • been tested in a test Druid cluster.

Key changed/added classes in this PR
  • LocalQuerySegmentWalker

@jihoonson jihoonson added this to the 0.18.0 milestone Mar 25, 2020
@jihoonson
Copy link
Contributor

Adding this PR for 0.18 since the laning feature is first introduced in it.

Copy link
Contributor

@jihoonson jihoonson left a comment

Choose a reason for hiding this comment

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

Code changes LGTM, left a couple of nit comments. I'm wondering whether we need some a bit detailed doc about how laning and prioritization work.

@@ -462,7 +462,8 @@ public QuerySwappingQueryRunner(QueryRunner<T> baseRunner, Query<T> query, Query
throw new ISE("Unexpected query received");
}

return baseRunner.run(queryPlus.withQuery(newQuery), responseContext);
Sequence<T> result = baseRunner.run(queryPlus.withQuery(newQuery), responseContext);
return result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary change?

{
Set<SegmentServerSelector> segmentServerSelectors = new HashSet<>();
for (Segment s : segments) {
segmentServerSelectors.add(new SegmentServerSelector(null, s.getId().toDescriptor()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you add @Nullable to the constructor parameter of SegmentServerSelector and getServer()?

@clintropolis
Copy link
Member Author

I'm wondering whether we need some a bit detailed doc about how laning and prioritization work.

This sounds nice, I will try to add an entry to the cluster tuning docs about this stuff before release (i guess that would be the most appropriate place)

Copy link
Contributor

@jihoonson jihoonson left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@clintropolis clintropolis merged commit fa5da66 into apache:master Mar 30, 2020
@clintropolis clintropolis deleted the joins-and-laning branch March 30, 2020 18:58
clintropolis added a commit to clintropolis/druid that referenced this pull request Mar 30, 2020
* add lane enforcement for joinish queries

* oops

* style

* review stuffs
clintropolis added a commit that referenced this pull request Mar 30, 2020
* add lane enforcement for joinish queries

* oops

* style

* review stuffs
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.

None yet

2 participants