-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support empty segments for realtime tables #13362
base: master
Are you sure you want to change the base?
Support empty segments for realtime tables #13362
Conversation
93aa00a
to
46469b5
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13362 +/- ##
============================================
+ Coverage 61.75% 61.98% +0.23%
+ Complexity 207 198 -9
============================================
Files 2436 2559 +123
Lines 133233 141215 +7982
Branches 20636 21916 +1280
============================================
+ Hits 82274 87533 +5259
- Misses 44911 47025 +2114
- Partials 6048 6657 +609
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
46469b5
to
5eb16f4
Compare
5eb16f4
to
a552211
Compare
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.
LGTM. @sajjad-moradi @mcvsubbu Do you have concern on allowing committing empty segment?
Sajjad and I will review this and get back to you. Please hold merging for a bit. |
I believe we already allow empty segments during force commit, so that by itself should not be a problem. @sajjad-moradi ? |
+1! |
Committing an empty segment is fine. I'm concerned that deleting the empty ones might make debugging a bit harder. If something goes wrong with segments of a partition, it would be hard by looking at IdealState, ExternalView, or SEGMENTS in PropertyStore to distinguish if a segment was purged due no-data case or something has indeed gone wrong. |
In that case, we can enable the empty segment retention manager behind a config: |
What is the current mechanism of removing empty segments? |
I believe the time-based retention manager should handle this since we get |
Good point on the infinite retention case. I'm okay always removing empty segment as long as it is not the last committed one (used to resume consumption or mark the end of a partition). I think it is okay because removed segments are either expired or empty. I don't see much value keeping all empty segments around even for debugging purpose. @sajjad-moradi wdyt? |
We won't have a lot of segments if we don't commit empty segments. A good thing about the existing behavior is that when we see a consuming segment that's started a long time ago, we can immediately tell that there hasn't been any new events on the stream, without needing for further investigation! To get around the issue that this PR is trying to fix, can't we just issue a force commit, and then deleted those segments? If you guys still think it's better to go with the approach suggested in this PR, let's have a config for committing empty consuming segment, and keep the existing behavior behind the default value of that config. |
@sajjad-moradi One problem with force commit is that it won't commit the empty segment for the same reason. |
We can monitor various metrics to determine if this scenario occurs after allowing this empty segments behaviour. I will move this empty segment behaviour behind a config but somehow I am not convinced to not make this default behaviour just because of better debuggability. It's just that overtime we will have to manage a lot of configs for getting the correct functionality out of Pinot. |
8cff8a6
to
246e376
Compare
246e376
to
12a7068
Compare
} | ||
_retentionStrategies.add(retentionStrategy); | ||
if (TableNameBuilder.isRealtimeTableResource(tableConfig.getTableName())) { | ||
_retentionStrategies.add(new EmptySegmentRetentionStrategy()); |
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.
Let's use a functional here to avoid creating a new class EmptySegmentRetentionStrategy
:
_retentionStrategies.add(new EmptySegmentRetentionStrategy()); | |
_retentionStrategies.add((tableName, segZkMetadata) -> segZkMetadata.getTotalDocs() == 0); |
return; | ||
} | ||
_retentionStrategies.add(retentionStrategy); | ||
if (TableNameBuilder.isRealtimeTableResource(tableConfig.getTableName())) { |
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.
Can you put this behind the config as well?
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.
Yeah I was thinking about that but we don't get instanceDataConfig
in the retention strategy. I kept this config at a cluster-level for easier rollout.
Either we should then define this config at a table level or pass instanceDataConfig here? Thoughts? cc @Jackie-Jiang
There are at least a couple of more considerations I can think of. @tibrewalpratik17 can you please follow up on these?
|
Thanks @mcvsubbu for the pointers! Briefly going through the code, I observe the following:
I noticed that we only update the stats when
Reviewing the implementation of |
After a second thought, the root cause of the problem is that: retention manager always keeps the last completed segment even if it is already expired. I think we need to fix this behavior because it is violating the retention agreement. |
but for very high / indefinite retention we would still end up with the consuming segment open for quite long. |
@tibrewalpratik17 Consuming segment will be opened for long time only if there is no event consumed. As long as we can clean up all the expired segments it should be fine |
Addresses #12703
This patch allows persistence of empty segments in case of no messages in realtime ingestion. Right now, it can happen that a segment is stuck in CONSUMING state for months / years if no offset advances for it.
We also add support for retention manager finding empty segments aggressively and purging them.