Vamsi-klu commented on code in PR #19370:
URL: https://github.com/apache/pinot/pull/19370#discussion_r4647653796


##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -820,6 +824,22 @@ public void run() {
         _segmentLogger.info("Starting consumption on segment: {}, maxRowCount: 
{}, maxEndTime: {}.", _llcSegmentName,
             _segmentMaxRowCount, new DateTime(_consumeEndTime, 
DateTimeZone.UTC));
 
+        // Create the stream consumer here (consumer thread) with 
CONSUMER_RECREATE_RETRY_POLICY. Doing this in
+        // the Helix constructor would either block the state-transition 
thread for the long retry window or keep
+        // the short Kafka 5x2s path and mark the replica OFFLINE. See
+        // https://github.com/apache/pinot/issues/11314 and 
https://github.com/apache/pinot/pull/17062.
+        if (_shouldStop) {
+          return;
+        }
+        makeStreamConsumer("Starting");
+        if (_shouldStop) {
+          // Leave a successfully created consumer in place so CONSUMING -> 
ONLINE can catch up.
+          return;

Review Comment:
   **Local validation update.** The repair and tests described below are staged 
locally. The published PR head is `825e2675d0`.
   
   ONLINE now joins the worker and can catch up once the worker has completed 
snapshot and primary-key TTL setup under the partition permit. If setup is 
incomplete when catch-up is needed, ONLINE downloads the committed segment. The 
regression interrupts the real worker during `start()`, then catches up A@110 
with TTL 20 and verifies that historical A@10 and B@100 stay valid, as they do 
after ordinary startup.
   
   Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting



##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -2266,17 +2307,26 @@ private void makeStreamConsumer(String reason) {
     }
   }
 
+  private void closeQuietly(PartitionGroupConsumer consumer) {
+    try {
+      consumer.close();
+    } catch (Exception e) {
+      _segmentLogger.warn("Could not close stream consumer", e);
+    }
+  }
+
   /// Checkpoints existing consumer before creating a new consumer instance
   /// Assumes there is a valid instance of [PartitionGroupConsumer]
   private void recreateStreamConsumer(String reason) {
     _segmentLogger.info("Recreating stream consumer for topic partition {}, 
reason: {}", _clientId, reason);
-    _currentOffset = _partitionGroupConsumer.checkpoint(_currentOffset);
+    _currentOffset = _partitionGroupConsumer.get().checkpoint(_currentOffset);
     closePartitionGroupConsumer();
     try {
-      _partitionGroupConsumer =
+      PartitionGroupConsumer consumer =
           _streamConsumerFactory.createPartitionGroupConsumer(_clientId, 
_partitionGroupConsumptionStatus,
               CONSUMER_RECREATE_RETRY_POLICY);
-      _partitionGroupConsumer.start(_currentOffset);
+      consumer.start(_currentOffset);
+      _partitionGroupConsumer.set(consumer);

Review Comment:
   **Local validation update.** The repair and tests described below are staged 
locally. The published PR head is `825e2675d0`.
   
   First creation and recreation share the start-and-publish path. When 
`start()` throws, the worker closes that exact candidate once and propagates 
the original startup exception, including when `close()` throws an 
`IOException`. Recreation still checkpoints the prior consumer before closing 
it. The tests cover both failure paths and successful replacement.
   
   Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting



-- 
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]

Reply via email to