xiangfu0 commented on code in PR #20441:
URL: https://github.com/apache/pinot/pull/20441#discussion_r4781008429
##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/BaseTaskExecutor.java:
##########
@@ -102,6 +105,46 @@ protected long getSegmentCrc(String tableNameWithType,
String segmentName) {
return segmentZKMetadata == null ? -1 : segmentZKMetadata.getCrc();
}
+ /// Returns the stream start/end offsets to keep when the given segment is
rebuilt under the same name, or `null` if
+ /// the segment has none.
+ ///
+ /// The offsets are not derived from the data, so they are lost unless
carried over to the rebuilt segment, and a
+ /// segment with LLC segment name needs them in order to be uploaded as a
new segment (e.g. to another table). The
+ /// ones recorded in the segment are preferred. A segment rebuilt before the
offsets were carried over no longer has
+ /// them, in which case the ones kept in the segment ZK metadata are used.
+ @Nullable
+ protected SegmentZKPropsConfig getStreamOffsets(String tableNameWithType,
String segmentName,
+ SegmentMetadata segmentMetadata) {
+ SegmentZKPropsConfig streamOffsets =
+ toStreamOffsets(segmentMetadata.getStartOffset(),
segmentMetadata.getEndOffset());
+ return streamOffsets != null ? streamOffsets :
getStreamOffsetsFromZK(tableNameWithType, segmentName);
Review Comment:
Follow-up in 73b3fcdb78: a rebuild now takes the offsets from the segment ZK
metadata first and only falls back to the ones recorded in the segment when ZK
has none. That closes this from the other side as well, since a rewrite carries
the exact ZK values and can no longer change them on re-upload. The whitespace
limit I mentioned above only applies to the fallback now, so it no longer
reaches a segment whose offsets are in ZK.
##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/purge/PurgeTaskExecutor.java:
##########
@@ -60,8 +61,11 @@ protected SegmentConversionResult convert(PinotTaskConfig
pinotTaskConfig, File
recordModifierFactory != null ?
recordModifierFactory.getRecordModifier(rawTableName) : null;
_eventObserver.notifyProgress(pinotTaskConfig, "Purging segment: " +
indexDir);
+ // The purger keeps the stream start/end offsets recorded in the segment.
A segment rebuilt before the offsets were
+ // carried over no longer has them, so also give it the ones kept in the
segment ZK metadata to fall back to.
SegmentPurger segmentPurger =
- new SegmentPurger(indexDir, workingDir, tableConfig, schema,
recordPurger, recordModifier, null);
+ new SegmentPurger(indexDir, workingDir, tableConfig, schema,
recordPurger, recordModifier, null,
+ getStreamOffsetsFromZK(tableNameWithType, segmentName));
Review Comment:
One correction after 73b3fcdb78: now that the ZK offsets are preferred, the
purger asks for them whenever it rebuilds a segment under the same name, not
only when an offset is missing. So it is one read per rebuilt real-time
segment, and still none for a scan that purges nothing. `PurgeTaskExecutorTest`
asserts both.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]