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

Restrict segment metadata kill query till maxInterval from last kill task time #17770

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

chetanpatidar26
Copy link
Contributor

@chetanpatidar26 chetanpatidar26 commented Mar 3, 2025

Description

In The current setup in killUnusedSegments, the segmentsMetadataManager.getUnusedSegmentIntervals queries for unused segments from the last segment kill time to the durationToRetain. This results in a expensive SQL query in some cases, where huge amount of segments are created in less time. Although we have a config druid.coordinator.kill.maxInterval which is set to 30 days by default, we are not using it. This config can be used to restrict the query to scan for only 30 days of data.

Example -
At confluent we create segments with granularity of 5 minutes, our current coordinator kill task is working on deleting segments from April 2022 and we have set durationToRetain=720 days. So everytime findIntervalToKill method runs it queries for segment data of nearly 350 days, this resulted in huge spike in handoff time.

We updated the durationToRetain=1000 days thus it resulted in scanning data of 50 days and handoff time was in control again.

Proposed fix

In findIntervalToKill method, restricting the maxEndTime to the maximum Interval from the time last segment was killed.

case 1

When a datasource is created and the first segment from it is killed we will have minStartTime as null because it is initialised as the end time of last segment killed, in this scenario the maxEndTime will be durationToRetain.

case 2

After the first segment is killed from this datasource the minStartTime will be initialised, thus now the maxEndTime will be
minimum(durationToRetain, minStartTime + maxInterval)

Release note



This PR has:

  • been self-reviewed.
  • 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
  • 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 is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@chetanpatidar26 chetanpatidar26 changed the title Restrict segment metadata kill query till maxInterval from last kill … Restrict segment metadata kill query till maxInterval from last kill task time Mar 3, 2025
@chetanpatidar26 chetanpatidar26 marked this pull request as ready for review March 3, 2025 06:55
@chetanpatidar26 chetanpatidar26 requested a review from kfaraz March 3, 2025 13:20
Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, @chetanpatidar26 !
The logic makes sense to me. I have left some suggestions.

@chetanpatidar26 chetanpatidar26 requested a review from kfaraz March 4, 2025 04:18
Copy link
Contributor

@kfaraz kfaraz left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution, @chetanpatidar26 !

@chetanpatidar26
Copy link
Contributor Author

Thanks for the review @kfaraz !
Thank you @rbankar7 for helping in fixing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants