noob-se7en commented on code in PR #20285:
URL: https://github.com/apache/pinot/pull/20285#discussion_r4626266288
##########
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:
I hope this will not break tables with time based segment flush threshold.
##########
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:
this is configurable time right?
##########
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) {
Review Comment:
[Agent] no test hits this branch: every extension in the new IT comes from
the committer at `END_OFFSET`, so the description's claim that an extension
from another server or offset fails without aborting the FSM isn't pinned (on
master a non-winner's extension inside the deadline was PROCESSED). sending one
as `OTHER_SERVER_INSTANCE` before the commit end in
`testPauselessLateBuildTimeExtension` (expect FAILED, then COMMIT_SUCCESS)
would cover it.
--
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]