-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add consensus check before selecting a segment for compaction or deletion #17352
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #17352 +/- ##
============================================
- Coverage 63.34% 63.30% -0.04%
- Complexity 1474 1476 +2
============================================
Files 3162 3162
Lines 188591 188611 +20
Branches 28857 28861 +4
============================================
- Hits 119454 119408 -46
- Misses 59891 59957 +66
Partials 9246 9246
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
...org/apache/pinot/plugin/minion/tasks/upsertcompactmerge/UpsertCompactMergeTaskGenerator.java
Outdated
Show resolved
Hide resolved
...org/apache/pinot/plugin/minion/tasks/upsertcompactmerge/UpsertCompactMergeTaskGenerator.java
Show resolved
Hide resolved
...org/apache/pinot/plugin/minion/tasks/upsertcompactmerge/UpsertCompactMergeTaskGenerator.java
Outdated
Show resolved
Hide resolved
...org/apache/pinot/plugin/minion/tasks/upsertcompactmerge/UpsertCompactMergeTaskGenerator.java
Outdated
Show resolved
Hide resolved
abce88c to
ee87a38
Compare
|
@tibrewalpratik17 @xiangfu0 can you please take a look at this? |
|
@xiangfu0 gentle bump on this. |
...org/apache/pinot/plugin/minion/tasks/upsertcompactmerge/UpsertCompactMergeTaskGenerator.java
Show resolved
Hide resolved
...minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/MinionTaskUtils.java
Show resolved
Hide resolved
e66919b to
dcee854
Compare
| * @param replicaMetadataList list of metadata from all replicas of the segment | ||
| * @return true if all replicas have consensus on validDoc counts, false otherwise | ||
| */ | ||
| public static boolean hasValidDocConsensus(String segmentName, |
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.
@tarun11Mavani : btw are we sure that there aren't some conditions where some deviation in valid counts across replicas are expected? (say due to live ingestion)
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 haven't seen this deviation due to live ingestion (have seen it after restart/replace) mostly.
I have added new metric , so we will be able to monitor if there is a large scale deviation across multiple segments.
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.
AFAIK the only issue we are aiming to solve is when we accidentally delete a segment when valid doc counts are incorrectly reported as zero.
Therefore should we just handle that case? I think by including deviations here we are increasing the scope which can have some other unintended effects (e.g. if due to some reason there's some minor discrepancy in reported valid doc counts, the upsert merge compact might progress very slowly)
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.
as discussed offline, The reason for skipping a segment when a deviation is detected is that using a validDocId (which may differ from the one on another replica for some reason) could potentially result in data loss. While I can’t think of a concrete scenario where this would happen, the risk still exists, so it’s safer to take a conservative approach.
we already have a metric to track skipped segment, I will monitor this for our production tables and if we see too many segment being skipped and impacting compaction throughput, we can revisit this check.
Problem
As discussed in #17337, Segments are incorrectly deleted when any single replica reported zero valid documents, causing permanent data loss during server restarts and async state transitions where replicas had inconsistent validDocIds.
Solution
Added consensus requirement: only delete/compact segments when ALL replicas agree on validDoc counts
Prevents race conditions during OFFLINE→ONLINE transitions and tie-breaking logic divergence
Changes
Tests
Deployed this change in a test cluster and see this warning message about skipping few segments due to validDocId mismatch.