xiangfu0 commented on code in PR #20285:
URL: https://github.com/apache/pinot/pull/20285#discussion_r4623145656
##########
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,
+ _segmentManager.getCurrentTimeMs())) {
+ _logger.warn("Rejecting commit end of segment: {} after the max
segment completion time", segmentName);
+ return SegmentCompletionProtocol.RESP_FAILED;
+ }
+ } catch (Exception e) {
+ _logger.error("Caught exception while checking segment ZK metadata
before the commit end of segment: {}",
+ segmentName, e);
+ return SegmentCompletionProtocol.RESP_FAILED;
+ }
+ return super.commitSegment(reqParams, committingSegmentDescriptor);
Review Comment:
[P1] Commit end can pass the checks just before the hard deadline, pause
here, and resume after validation has published another replica’s copy and
marked it DONE. `super.commitSegment()` then overwrites the repaired file
before its metadata update fails. That can leave ZooKeeper advertising the
repair’s CRC for different bytes in deep store. Can we make commit and repair
coordinate publication so the losing writer cannot replace the winning file? A
regression test could pause commit end here, complete repair, then resume
commit end and verify the repaired bytes still match the recorded CRC.
##########
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;
Review Comment:
[P2] If the winner disappears after commit start, validation can repair the
segment and mark it DONE while the controller still has this FSM cached in
COMMITTER_UPLOADING. A non-winner reporting an offset above `_winningOffset`
then keeps getting HOLD from `handleNonWinnerCase`, even though a fresh FSM
would return DISCARD. Can we keep ignoring the soft deadline but reconcile or
retire the cached FSM once the hard deadline passes? A test with no further
messages from the winner should verify the non-winner gets DISCARD after repair.
--
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]