kamalcph commented on code in PR #14127:
URL: https://github.com/apache/kafka/pull/14127#discussion_r1300343897


##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/RemoteLogMetadataCache.java:
##########
@@ -104,6 +106,22 @@ public class RemoteLogMetadataCache {
     // https://issues.apache.org/jira/browse/KAFKA-12641
     protected final ConcurrentMap<Integer, RemoteLogLeaderEpochState> 
leaderEpochEntries = new ConcurrentHashMap<>();
 
+    private final CountDownLatch initializedLatch = new CountDownLatch(1);
+
+    public void markInitialized() {
+        initializedLatch.countDown();
+    }
+
+    public void ensureInitialized() throws InterruptedException {
+        if (!initializedLatch.await(2, TimeUnit.MINUTES)) {

Review Comment:
   The java client retries when it receives `UNKNOWN_SERVER_ERROR` not sure for 
other clients. As per the protocol contract, the clients are not expected to 
retry when it receives this error.
   
   We also have one more API `isInitialized` that can be used instead of 
`ensureInitialized` if we want to unblock the caller immediately. This latch 
will only block the remote-log-reader and remote-log-deleter threads until the 
partition gets initialised and won't block the request handler threads.
   
   The idea to increase the timeout upto 2 minutes was similar to delayed 
purgatory where the requests are hold until it gets served within the request 
timeout. 



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to