9aman commented on code in PR #20285:
URL: https://github.com/apache/pinot/pull/20285#discussion_r4626689680
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PauselessSegmentCompletionFSM.java:
##########
@@ -93,6 +99,74 @@ public SegmentCompletionProtocol.Response
extendBuildTime(final String instanceI
}
}
+ /// Reached only in COMMITTER_UPLOADING (see [#extendBuildTime]). Accepts an
extension from the committer even after
+ /// the commit deadline or past
[SegmentCompletionManager#getMaxCommitTimeForAllSegmentsSeconds()]. Fails an
+ /// extension from any other server or for any other offset, without
aborting the FSM.
+ @Override
+ protected SegmentCompletionProtocol.Response
committerNotifiedExtendBuildTime(String instanceId,
+ StreamPartitionMsgOffset offset, int extTimeSec, long now) {
+ if (!instanceId.equals(_winner) || offset.compareTo(_winningOffset) != 0) {
+ return fail(instanceId, offset);
+ }
+ logIfPastCommitDeadline(now, instanceId, offset);
+ // After the commit start, the commit deadline only decides which requests
are logged as late
+ _maxTimeAllowedToCommitMs = now + extTimeSec * 1000L;
+ return SegmentCompletionProtocol.RESP_PROCESSED;
+ }
+
+ /// After the commit start, the commit deadline does not abort the FSM: an
abort cannot hand the commit to another
+ /// replica, it only makes the commit end of the committer fail. Before the
commit start, the deadline lets another
+ /// replica take the commit over, as for a blocking table.
+ @Override
+ protected SegmentCompletionProtocol.Response
abortIfTooLateAndReturnHold(long now, String instanceId,
+ StreamPartitionMsgOffset offset) {
+ if (_state != BlockingSegmentCompletionFSMState.COMMITTER_UPLOADING
+ && _state != BlockingSegmentCompletionFSMState.COMMITTING) {
+ return super.abortIfTooLateAndReturnHold(now, instanceId, offset);
+ }
+ logIfPastCommitDeadline(now, instanceId, offset);
+ return null;
+ }
+
+ private void logIfPastCommitDeadline(long now, String instanceId,
StreamPartitionMsgOffset offset) {
+ if (now > _maxTimeAllowedToCommitMs) {
+ _logger.info("{}:Ignoring commit deadline after commit start (too late)
instance={} offset={} now={} start={}",
+ _state, instanceId, offset, now, _startTimeMs);
+ }
+ }
+
+ /// Checks the segment ZK metadata before the commit end moves the uploaded
segment file to the deep store path of the
+ /// segment: the segment must still be COMMITTING with the end offset of
this commit, within the max segment
+ /// completion time. The ZK metadata update after the move checks the status
and the time too, but after the max
+ /// segment completion time the validation manager may already have uploaded
another replica's copy to that path,
+ /// and the move would overwrite it.
+ @Override
+ protected SegmentCompletionProtocol.Response
commitSegment(SegmentCompletionProtocol.Request.Params reqParams,
+ CommittingSegmentDescriptor committingSegmentDescriptor) {
+ String segmentName = _segmentName.getSegmentName();
+ StreamPartitionMsgOffset offset =
_streamPartitionMsgOffsetFactory.create(reqParams.getStreamPartitionMsgOffset());
+ try {
+ SegmentZKMetadata segmentZKMetadata =
_segmentManager.getSegmentZKMetadata(_realtimeTableName, segmentName, null);
+ String endOffset = segmentZKMetadata.getEndOffset();
+ if (segmentZKMetadata.getStatus() != Status.COMMITTING || endOffset ==
null
+ ||
_streamPartitionMsgOffsetFactory.create(endOffset).compareTo(offset) != 0) {
Review Comment:
It does not change them. This check compares the end offset that the
committer wrote to ZK at commit start with the offset of its own commit end,
and `segmentCommitEnd` already requires the same committer and offset. Both
limits count from the FSM start and from the commit start, not from the segment
creation time. With a time threshold, other replicas often stop at another
offset. They still get KEEP, CATCHUP or HOLD, as before.
##########
pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PauselessSegmentCompletionFSM.java:
##########
@@ -93,6 +99,74 @@ public SegmentCompletionProtocol.Response
extendBuildTime(final String instanceI
}
}
+ /// Reached only in COMMITTER_UPLOADING (see [#extendBuildTime]). Accepts an
extension from the committer even after
+ /// the commit deadline or past
[SegmentCompletionManager#getMaxCommitTimeForAllSegmentsSeconds()]. Fails an
+ /// extension from any other server or for any other offset, without
aborting the FSM.
+ @Override
+ protected SegmentCompletionProtocol.Response
committerNotifiedExtendBuildTime(String instanceId,
+ StreamPartitionMsgOffset offset, int extTimeSec, long now) {
+ if (!instanceId.equals(_winner) || offset.compareTo(_winningOffset) != 0) {
+ return fail(instanceId, offset);
+ }
+ logIfPastCommitDeadline(now, instanceId, offset);
+ // After the commit start, the commit deadline only decides which requests
are logged as late
+ _maxTimeAllowedToCommitMs = now + extTimeSec * 1000L;
+ return SegmentCompletionProtocol.RESP_PROCESSED;
+ }
+
+ /// After the commit start, the commit deadline does not abort the FSM: an
abort cannot hand the commit to another
+ /// replica, it only makes the commit end of the committer fail. Before the
commit start, the deadline lets another
+ /// replica take the commit over, as for a blocking table.
+ @Override
+ protected SegmentCompletionProtocol.Response
abortIfTooLateAndReturnHold(long now, String instanceId,
+ StreamPartitionMsgOffset offset) {
+ if (_state != BlockingSegmentCompletionFSMState.COMMITTER_UPLOADING
+ && _state != BlockingSegmentCompletionFSMState.COMMITTING) {
+ return super.abortIfTooLateAndReturnHold(now, instanceId, offset);
+ }
+ logIfPastCommitDeadline(now, instanceId, offset);
+ return null;
+ }
+
+ private void logIfPastCommitDeadline(long now, String instanceId,
StreamPartitionMsgOffset offset) {
+ if (now > _maxTimeAllowedToCommitMs) {
+ _logger.info("{}:Ignoring commit deadline after commit start (too late)
instance={} offset={} now={} start={}",
+ _state, instanceId, offset, now, _startTimeMs);
+ }
+ }
+
+ /// Checks the segment ZK metadata before the commit end moves the uploaded
segment file to the deep store path of the
+ /// segment: the segment must still be COMMITTING with the end offset of
this commit, within the max segment
+ /// completion time. The ZK metadata update after the move checks the status
and the time too, but after the max
+ /// segment completion time the validation manager may already have uploaded
another replica's copy to that path,
+ /// and the move would overwrite it.
+ @Override
+ protected SegmentCompletionProtocol.Response
commitSegment(SegmentCompletionProtocol.Request.Params reqParams,
+ CommittingSegmentDescriptor committingSegmentDescriptor) {
+ String segmentName = _segmentName.getSegmentName();
+ StreamPartitionMsgOffset offset =
_streamPartitionMsgOffsetFactory.create(reqParams.getStreamPartitionMsgOffset());
+ try {
+ SegmentZKMetadata segmentZKMetadata =
_segmentManager.getSegmentZKMetadata(_realtimeTableName, segmentName, null);
+ String endOffset = segmentZKMetadata.getEndOffset();
+ if (segmentZKMetadata.getStatus() != Status.COMMITTING || endOffset ==
null
+ ||
_streamPartitionMsgOffsetFactory.create(endOffset).compareTo(offset) != 0) {
+ _logger.warn("Rejecting commit end of segment: {} at offset: {},
segment ZK status: {}, end offset: {}",
+ segmentName, offset, segmentZKMetadata.getStatus(), endOffset);
+ return SegmentCompletionProtocol.RESP_FAILED;
+ }
+ if
(_segmentManager.isExceededMaxSegmentCompletionTime(_realtimeTableName,
segmentName,
Review Comment:
Yes. It is the cluster config `max.segment.completion.time.millis` (default
300000 ms). The controller applies a change without a restart.
--
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]