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

(perf) server: batch SQL Metadata deleteSegments #14639

Merged
merged 4 commits into from
Jul 23, 2023

Conversation

jasonk000
Copy link
Contributor

@jasonk000 jasonk000 commented Jul 21, 2023

Related to #14634.

Description

Introduce batching to mitigate some scaling challenges while managing lots of segments.

This PR introduces changes to IndexerSQLMetadataStorageCoordinator to use the JDBI PreparedBatch instead of issuing single update statements inside a transaction.

Context - in our environment, bulk cleanup of old segments (O(thousands)) stalls the overlord, because the overlord is issuing delete statements. These delete statements are done while holding the TaskLockbox lock, which is done from the TaskQueue, so the whole overlord locks up until the delete statements are complete. By pushing these into a single bulk transaction we see a meaningful improvement: previously ~1000 rows/sec removed, after ~1800 rows/sec removed.

Key changed/added classes in this PR
  • IndexerSQLMetadataStorageCoordinator: use PreparedBatch instead of single statements.

This PR has:

  • been self-reviewed.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • been tested in a test Druid cluster.

@jasonk000 jasonk000 requested review from kfaraz and removed request for zhangyue19921010 July 21, 2023 18:25
@jasonk000 jasonk000 marked this pull request as ready for review July 21, 2023 21:03
Copy link
Contributor

@abhishekrb19 abhishekrb19 left a comment

Choose a reason for hiding this comment

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

The overall approach looks good to me. I left a few comments around batch size and transaction code blocks. Thanks!

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 taking this up, @jasonk000 ! I have left some suggestions.

…adata

pr feedback:
- extract batch update and delete data generation outside of the SQL transaction,
- avoid a query altogether if there are no segments to add,
- improvement to logging
removed the updateSegmentMetadata batching since it is dead code
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.

Final nitpicks.

pr feedback
- improve logging accuracy
- restore missing newline
@jasonk000
Copy link
Contributor Author

Final nitpicks.

Much appreciated @kfaraz, all good suggestions. Fixed in d28f768.

@jasonk000 jasonk000 changed the title (perf) server: batch SQL Metadata deleteSegments and updateSegmentMetadata (perf) server: batch SQL Metadata deleteSegments Jul 23, 2023
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 quick fix, @jasonk000 !

@kfaraz kfaraz merged commit 54f29fe into apache:master Jul 23, 2023
75 checks passed
@maytasm
Copy link
Contributor

maytasm commented Jul 24, 2023

A bit late to the PR. Change looks good to me. Thank you for the PR!

Copy link
Contributor

@maytasm maytasm left a comment

Choose a reason for hiding this comment

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

+1

@LakshSingla LakshSingla added this to the 28.0 milestone Oct 12, 2023
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.

5 participants