-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Auto-Compaction using Multi-Stage Query Engine #16291
Conversation
# Conflicts: # indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java # server/src/main/java/org/apache/druid/server/coordinator/CoordinatorCompactionConfig.java
server/src/main/java/org/apache/druid/server/coordinator/DataSourceCompactionConfig.java
Fixed
Show fixed
Hide fixed
...multi-stage-query/src/main/java/org/apache/druid/msq/compaction/CompactionToMSQTaskImpl.java
Fixed
Show fixed
Hide fixed
server/src/main/java/org/apache/druid/server/coordinator/DataSourceCompactionConfig.java
Fixed
Show fixed
Hide fixed
@gargvishesh , I concur with @LakshSingla on this one. We need UTs to test the entire flow with MSQ the same way we are doing with native. We may add ITs too but most Druid devs rely on UTs more heavily as the IT flow is a little flaky currently.
|
@@ -305,17 +305,30 @@ private CompactionStatus metricsSpecIsUpToDate() | |||
if (ArrayUtils.isEmpty(configuredMetricsSpec)) { | |||
return COMPLETE; | |||
} | |||
final AggregatorFactory[] configuredMetricsCombiningFactorySpec = |
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.
Why are we comparing just the combining factory now and not the original AggregatorFactory itself? Please add comments (and tests, if not already added) to clarity this change.
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.
Added it as a javadoc for the function
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 would advise retaining the old version of the code and doing this change in a follow up. In the current PR, I would prefer it if we didn't modify any of the logic for native compaction. What happens if we just stick to the old logic?
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.
With the last change to unsupport problematic aggregator factory definitions, this change is not required. Have reverted it.
server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/coordinator/duty/CompactSegmentsTest.java
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/coordinator/DataSourceCompactionConfigTest.java
Show resolved
Hide resolved
server/src/main/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResource.java
Show resolved
Hide resolved
server/src/main/java/org/apache/druid/server/coordinator/duty/CompactSegments.java
Outdated
Show resolved
Hide resolved
@kfaraz @LakshSingla |
server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java
Fixed
Show fixed
Hide fixed
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.
Please resolve merge conflicts in the PR.
It has been introduced by a recent NPE bugfix in #16713 .
I think this bugfix is also included in the current PR but I decided merged it separately as it has been reported in community in a couple of places.
Sorry for the inconvenience!
server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/http/CoordinatorCompactionConfigsResourceTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/coordinator/DataSourceCompactionConfigTest.java
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/coordinator/duty/CompactSegmentsTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/coordinator/duty/CompactSegmentsTest.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/druid/server/coordinator/duty/CompactSegmentsTest.java
Show resolved
Hide resolved
server/src/main/java/org/apache/druid/server/coordinator/duty/CompactSegments.java
Outdated
Show resolved
Hide resolved
...ration-tests/src/test/java/org/apache/druid/tests/coordinator/duty/ITAutoCompactionTest.java
Outdated
Show resolved
Hide resolved
# Conflicts: # server/src/main/java/org/apache/druid/server/coordinator/duty/CompactSegments.java
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.
Thanks a lot for taking this PR to completion, @gargvishesh !
You have been a great sport with addressing the multiple rounds of feedback. 🚀
Thank you @kfaraz, @LakshSingla and @cryptoe for the time and effort to do all those rounds of reviews, esp. given the size of the PR. |
Follow-up to #16291, this commit enables a subset of existing native compaction ITs on the MSQ engine. In the process, the following changes have been introduced in the MSQ compaction flow: - Populate `metricsSpec` in `CompactionState` from `querySpec` in `MSQControllerTask` instead of `dataSchema` - Add check for pre-rolled-up segments having `AggregatorFactory` with different input and output column names - Fix passing missing cluster-by clause in scan queries - Add annotation of `CompactionState` to tombstone segments
Description: Compaction operations issued by the Coordinator currently run using the native query engine. As majority of the advancements that we are making in batch ingestion are in MSQ, it is imperative that we support compaction on MSQ to make Compaction more robust and possibly faster. For instance, we have seen OOM errors in native compaction that MSQ could have handled by its auto-calculation of tuning parameters. This commit enables compaction on MSQ to remove the dependency on native engine. Main changes: * `DataSourceCompactionConfig` now has an additional field `engine` that can be one of `[native, msq]` with `native` being the default. * if engine is MSQ, `CompactSegments` duty assigns all available compaction task slots to the launched `CompactionTask` to ensure full capacity is available to MSQ. This is to avoid stalling which could happen in case a fraction of the tasks were allotted and they eventually fell short of the number of tasks required by the MSQ engine to run the compaction. * `ClientCompactionTaskQuery` has a new field `compactionRunner` with just one `engine` field. * `CompactionTask` now has `CompactionRunner` interface instance with its implementations `NativeCompactinRunner` and `MSQCompactionRunner` in the `druid-multi-stage-query` extension. The objectmapper deserializes `ClientCompactionRunnerInfo` in `ClientCompactionTaskQuery` to the `CompactionRunner` instance that is mapped to the specified type [`native`, `msq`]. * `CompactTask` uses the `CompactionRunner` instance it receives to create the indexing tasks. * `CompactionTask` to `MSQControllerTask` conversion logic checks whether metrics are present in the segment schema. If present, the task is created with a native group-by query; if not, the task is issued with a scan query. The `storeCompactionState` flag is set in the context. * Each created `MSQControllerTask` is launched in-place and its `TaskStatus` tracked to determine the final status of the `CompactionTask`. The id of each of these tasks is the same as that of `CompactionTask` since otherwise, the workers will be unable to determine the controller task's location for communication (as they haven't been launched via the overlord).
Follow-up to apache#16291, this commit enables a subset of existing native compaction ITs on the MSQ engine. In the process, the following changes have been introduced in the MSQ compaction flow: - Populate `metricsSpec` in `CompactionState` from `querySpec` in `MSQControllerTask` instead of `dataSchema` - Add check for pre-rolled-up segments having `AggregatorFactory` with different input and output column names - Fix passing missing cluster-by clause in scan queries - Add annotation of `CompactionState` to tombstone segments
Description
Compaction operations issued by the Coordinator currently run using the native query engine. As majority of the advancements that we are making in batch ingestion are in MSQ, it is imperative that we support compaction on MSQ to make Compaction more robust and possibly faster. For instance, we have seen OOM errors in native compaction that MSQ could have handled by its auto-calculation of tuning parameters.
This PR enables compaction on MSQ to remove the dependency on native engine.
Main changes:
DataSourceCompactionConfig
now has an additional fieldengine
that can be one among[native, msq]
withnative
being the default.CompactSegments
duty assigns all available compaction task slots to the launchedCompactionTask
to ensure full capacity is available to MSQ. This is to avoid stalling which could happen in case a fraction of the tasks were allotted and they eventually fell short of the number of tasks required by the MSQ engine to run the compaction.ClientCompactionTaskQuery
has a new fieldClientCompactionRunnerInfo
with just oneEngine
subfield.CompactionTask
now hasCompactionRunner
interface instance with its implementationsNativeCompactinRunner
in core andMSQCompactionRunner
in thedruid-multi-stage-query
extension. . The objectmapper deserializesClientCompactionRunnerInfo
inClientCompactionTaskQuery
to theCompactionRunner
instance that is mapped to the specified type [native
,msq
].CompactTask
uses theCompactionRunner
instance it receives to create the indexing tasks.CompactionTask
toMSQControllerTask
conversion logic checks whether metrics are present in the segment schema. If present, the task is created with a native group-by query; if not, the task is issued with a scan query. ThestoreCompactionState
flag is set in the context.MSQControllerTask
is launched in-place and itsTaskStatus
tracked to determine the final status ofthe
CompactionTask
. The id of each of these tasks is the same as that ofCompactionTask
since otherwise, the workers will be unable to determine the controller task's location for communication (as they haven't been launched via the overlord).Some things to note:
DataSourceCompactionConfig
is passed as is to the MSQControllerTask and hence can contain MSQ context params as well, with the exception ofrowsPerSegment
-- which will be overridden by eithertargetRowsPerSegment
ormaxRowsPerSegment
if specified in apartitionsSpec
.maxRowsInMemory
param is only considered if specified in the context. The value in DataSourceCompactionConfig.tuningConfig is not considered as it is set to a default value (1M) if unspecified by a user, so it is indistinguishable between coming from the user or via the default.maxNumTasks
value is specified in thetaskContext
,min(availableCompactionTaskSlots, 5)
is allotted to MSQ compaction tasks.rollup:true
without anymetricsSpec
de-duplicates rows since all columns are then treated as dimensions -- just as in native compaction.Currently unsupported for MSQ Compaction:
native
which can be updated at a per-datasource level. The cluster-level update API will come in a follow-up PR.groupByEnableMultiValueUnnesting
is disabled. Only array-type columns are supportedpartitionsSpec
of typeHashedParititionsSpec
. OnlyDimensionRangePartitionsSpec
andDynamicPartitionsSpec
works.maxTotalRows
inDynamicPartitionsSpec
. OnlymaxRowsPerSegment
works.rollup
set to false ingranularitySpec
whenmetricsSpec
is specified. Onlyrollup
set totrue
works with a non-emptymetricsSpec
.metricsSpec
wherefieldName != name
OR (internal)aggregatorFactory.class() != aggregatorFactory.getCombiningFactory.class()
. This is a major limitation that will be addressed in a follow-up PRRelease note
Key changed/added classes in this PR
MyFoo
OurBar
TheirBaz
This PR has: