kfaraz commented on code in PR #16844:
URL: https://github.com/apache/druid/pull/16844#discussion_r1708514241
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -3616,8 +3616,26 @@ private void checkIfStreamInactiveAndTurnSupervisorIdle()
return;
}
- Map<PartitionIdType, SequenceOffsetType> latestSequencesFromStream =
getLatestSequencesFromStream();
final long nowTime = DateTimes.nowUtc().getMillis();
+ // if it is the first run and there is no lag observed when compared to
the offsets from metadata storage stay idle
+ if (!stateManager.isAtLeastOneSuccessfulRun()) {
+ lastActiveTimeMillis = nowTime;
+ Map<PartitionIdType, SequenceOffsetType> comittedOffsets =
getOffsetsFromMetadataStorage();
+ if (comittedOffsets.isEmpty()) {
+ // since there is no previous offsets info available we can skip
checking for idleness
+ return;
+ }
+
+ updatePartitionLagFromStream();
+ Map<PartitionIdType, SequenceOffsetType> latestSequencesFromStream =
getLatestSequencesFromStream();
+ if (comittedOffsets.equals(latestSequencesFromStream)) {
+ stateManager.maybeSetState(SupervisorStateManager.BasicState.IDLE);
+ previousSequencesFromStream.putAll(comittedOffsets);
+ }
+ return;
Review Comment:
Would it work if we just did this instead?
```suggestion
// Set previous sequences to the current offsets in metadata store
previousSequencesFromStream.clear();
previousSequencesFromStream.putAll(getOffsetsFromMetadataStorage());
// Force update partition lag since the reporting thread might not
have run yet
updatePartitionLagFromStream();
```
The code after this would take care of the rest (once we remove the
condition `lastActiveTimeMillis > 0` from the `if` clause).
##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -3616,8 +3616,26 @@ private void checkIfStreamInactiveAndTurnSupervisorIdle()
return;
}
- Map<PartitionIdType, SequenceOffsetType> latestSequencesFromStream =
getLatestSequencesFromStream();
final long nowTime = DateTimes.nowUtc().getMillis();
+ // if it is the first run and there is no lag observed when compared to
the offsets from metadata storage stay idle
+ if (!stateManager.isAtLeastOneSuccessfulRun()) {
Review Comment:
I wonder if we should revisit this condition. This will hold true even when
there have been multiple runs, none of which have been successful. Would we
want to keep checking for idleness then? I guess it's okay. 🤷🏻
--
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]