KKcorps commented on code in PR #10826:
URL: https://github.com/apache/pinot/pull/10826#discussion_r1217742086
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -662,6 +659,46 @@ public void run() {
long catchUpTimeMillis = 0L;
_startTimeMs = now();
try {
+ if (!_isReadyToConsumeData.getAsBoolean()) {
+ do {
+ //noinspection BusyWait
+
Thread.sleep(RealtimeTableDataManager.READY_TO_CONSUME_DATA_CHECK_INTERVAL_MS);
+ } while (!_shouldStop && !endCriteriaReached() &&
!_isReadyToConsumeData.getAsBoolean());
+ }
+
+ if (_tableConfig.getUpsertConfig() != null &&
_tableConfig.getUpsertConfig().isEnableSnapshot()) {
+ // Persist snapshot for sealed segments. We need to guarantee the
previous segment is already replaced with
+ // the immutable segment, so the snapshot might not be persisted for
the previous consuming segment.
+ List<SegmentDataManager> allSegments =
_realtimeTableDataManager.acquireAllSegments();
+ List<SegmentDataManager> allSegmentsForPartition =
_realtimeTableDataManager.acquireAllSegments();
+ for (SegmentDataManager segmentDataManager: allSegments) {
+ // release segments not this partition
+ if (_partitionGroupId == new
LLCSegmentName(segmentDataManager.getSegmentName()).getPartitionGroupId()) {
+ allSegmentsForPartition.add(segmentDataManager);
+ } else {
+ _realtimeTableDataManager.releaseSegment(segmentDataManager);
+ }
+ }
+ // wait if all segments for this partition not sealed completely
+ if (allSegmentsForPartition.stream().anyMatch(
+ segmentDataManager ->
segmentDataManager.getSegment().getSegmentMetadata().isMutableSegment())) {
+ do {
+ //noinspection BusyWait
+
Thread.sleep(RealtimeTableDataManager.READY_TO_CONSUME_DATA_CHECK_INTERVAL_MS);
+ } while (allSegmentsForPartition.stream().anyMatch(
+ segmentDataManager ->
!segmentDataManager.getSegment().getSegmentMetadata().isMutableSegment()));
+ }
+ // Persist snapshot and release all the segments for this partition,
they should be immutableSegments.
+ for (SegmentDataManager segmentDataManager: allSegmentsForPartition)
{
+ assert segmentDataManager.getSegment() instanceof ImmutableSegment;
+ if (segmentDataManager.getSegment().getValidDocIds() != null) {
+ MutableRoaringBitmap validDocIds =
+
segmentDataManager.getSegment().getValidDocIds().getMutableRoaringBitmap();
+ ((ImmutableSegmentImpl)
segmentDataManager.getSegment()).persistValidDocIdsSnapshot(validDocIds);
Review Comment:
Would it be possible to add a `.snapshot` method to upsert metadata manager
itself which takes care of the snapshot logic.
--
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]