Skip to content

Add test and metrics for KillStalePendingSegments duty#14951

Merged
kfaraz merged 4 commits intoapache:masterfrom
kfaraz:reduce_kill_pending_logs
Sep 8, 2023
Merged

Add test and metrics for KillStalePendingSegments duty#14951
kfaraz merged 4 commits intoapache:masterfrom
kfaraz:reduce_kill_pending_logs

Conversation

@kfaraz
Copy link
Copy Markdown
Contributor

@kfaraz kfaraz commented Sep 7, 2023

Changes

  • Add new metric kill/pendingSegments/count with dimension dataSource
  • Add tests for KillStalePendingSegments
  • Reduce no-op logs that are currently spit out for each datasource even when no pending segments have been deleted. This can get particularly noisy at low values of indexingPeriod.
  • Refactor the code in KillStalePendingSegments for readability and add javadocs

Release Note

  • Add new metric kill/pendingSegments/count that reports the number of stale pending segments deleted from the metadata store for each datasource.

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.

DateTime latestCompletedTaskStart = null;
for (TaskStatusPlus status : statuses) {
if (status.getStatusCode() == null) {
// Unknown status
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There seems to be a change in logic here as the created time was processed in the earlier code:
.filter(status -> status.getStatusCode() == null || !status.getStatusCode().isComplete())

Copy link
Copy Markdown
Contributor Author

@kfaraz kfaraz Sep 8, 2023

Choose a reason for hiding this comment

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

Ah, thanks for catching this! This is why we should always have some unit tests.

Copy link
Copy Markdown
Contributor Author

@kfaraz kfaraz Sep 8, 2023

Choose a reason for hiding this comment

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

I have made the changes but is it okay with you if I include it in a separate PR? I don't want to trigger the whole CI pipeline for this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, I'm ok with it.

Copy link
Copy Markdown
Contributor Author

@kfaraz kfaraz Sep 8, 2023

Choose a reason for hiding this comment

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

Fixed in #14891 #14961

"Killed [%d] pendingSegments created before [%s] for datasource[%s].",
pendingSegmentsKilled, minCreatedTime, dataSource
);
params.getCoordinatorStats().add(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not add the stats to emit metrics even when the number of pending segments killed is 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just avoiding zero value metric emissions for now, as this is a new metric.

Copy link
Copy Markdown
Contributor

@AmatyaAvadhanula AmatyaAvadhanula left a comment

Choose a reason for hiding this comment

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

Approving since the changes suggested will be added in a new PR as discussed at #14951 (comment)

@kfaraz kfaraz merged commit 647686a into apache:master Sep 8, 2023
@kfaraz
Copy link
Copy Markdown
Contributor Author

kfaraz commented Sep 8, 2023

Thanks for the review, @AmatyaAvadhanula !

@kfaraz kfaraz deleted the reduce_kill_pending_logs branch September 8, 2023 05:03
@kfaraz
Copy link
Copy Markdown
Contributor Author

kfaraz commented Sep 8, 2023

Fixed the bug identified in this PR as a part of #14891 #14961

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.

3 participants