kfaraz opened a new pull request, #16768:
URL: https://github.com/apache/druid/pull/16768
### Description
Auto-compaction currently poses several challenges:
- gets stuck on a failing interval.
- gets stuck on the latest interval if more data keeps coming into it.
- may cause starvation of a datasource if its intervals are not very recent.
- always picks latest interval regardless of the level of compaction in it.
- requires setting an explicit period which does not cater to the changing
needs of a Druid cluster.
### Summary of design
- Create a new Compaction Scheduler that runs on the Overlord.
- Scheduler continuously watches for compaction slots to become available
and can run on demand.
- It keeps track of repeatedly failing intervals and recently compacted
intervals to avoid re-queueing
them immediately.
- Overlord now polls segments from the metadata store and builds a timeline
to identify compactible segments.
- Coordinator does not run auto-compaction duty if scheduler is enabled on
Overlord.
- Compaction policy now offers 3 choices:
- `newestSegmentFirst`: current default policy
- `smallestSegmentFirst`: prefers compacting intervals with the smallest
segments first
i.e. the interval with the lowest `bytes/numSegments` ratio.
- `auto`: experimental policy that may evolve over time to best optimize
compaction resources
- Compaction config may also specify a `priorityDatasource` along with any
policy to prioritize that
datasource over all others. Other datasources are picked for compaction only
after __all__ the intervals
of the priority datasource have been compacted.
- The router redirects compaction progress APIs to Overlord instead of
Coordinator
- Compaction configs are still maintained by Coordinator but Overlord
watches them for changes
### Using the new scheduler
- Set the following property on Coordinator, Overlord and Router
`runtime.properties`:
`druid.compaction.scheduler.enabled=true`
- The scheduler does not require a period to be specified and runs as soon
as compaction slots become available.
- Set the policy and priorityDatasource in the compaction config as follows:
```java
{
...
"maxCompactionTaskSlots": 4,
"compactionTaskSlotRatio": 0.1,
"compactionPolicy": { // nullable
"type": "newestSegmentFirst", // not nullable
"priorityDatasource": "wikipedia" // nullable
}
...
}
```
### Design details
#### Running on the Overlord
Running on Overlord has the following advantages:
- Scheduler can listen for changes in task statuses and update the job queue
accordingly.
- Scheduler can track status of submitted, failing and succeeded tasks to
determine if an interval needs
to be sidelined. Once sidelined, an interval does not become eligible for
compaction until a few other intervals
from that same datasource have been given a chance.
- In the future, we may also be able to use the stats captured in task
reports to prioritize intervals based
on the expected benefit from compacting an interval.
- Scheduler has the same role as a streaming supervisor, i.e. launching and
killing tasks as necessary.
Thus Overlord is the natural place to run it.
### Main classes to review
- `CompactionSchedulerImpl`
- `CompactionStatusTracker`
- `BaseSegmentSearchPolicy`
### Testing
- [ ] Small local Druid cluster
- [ ] Unit tests
- [ ] Integration tests
- [ ] Large Druid cluster
### Release note
- [ ] Pending
<hr>
This PR has:
- [ ] been self-reviewed.
- [ ] using the [concurrency
checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md)
(Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked
related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] 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,
ensuring the threshold for [code
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
is met.
- [ ] added integration tests.
- [ ] been tested in a test Druid cluster.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]