You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "junrao (via GitHub)" <gi...@apache.org> on 2023/05/12 16:54:36 UTC

[GitHub] [kafka] junrao commented on a diff in pull request #13689: KAFKA-14975: Wait for TopicBasedRemoteLogMetadataManager.ensureInitializedAndNotClosed to initialize rather than throwing

junrao commented on code in PR #13689:
URL: https://github.com/apache/kafka/pull/13689#discussion_r1192604258


##########
storage/src/main/java/org/apache/kafka/server/log/remote/metadata/storage/TopicBasedRemoteLogMetadataManager.java:
##########
@@ -489,14 +498,28 @@ public boolean isInitialized() {
         return initialized.get();
     }
 
-    private void ensureInitializedAndNotClosed() {
+    private void ensureInitializedAndNotClosed() throws RemoteStorageException {
         if (initializationFailed) {
             // If initialization is failed, shutdown the broker.
             throw new FatalExitError();
         }
-        if (closing.get() || !initialized.get()) {
-            throw new IllegalStateException("This instance is in invalid state, initialized: " + initialized +
-                                                    " close: " + closing);
+
+        if (!initialized.get()) {
+            log.info("Waiting for TopicBasedRemoteLogMetadataManager to initialize");
+            try {
+                if (!initializeLatch.await(SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {

Review Comment:
   Hmm, if we wait here, it could tie up the caller thread for 60 secs. Some of the caller threads may be very limited. So, it's probably better to fail immediately instead of block?



-- 
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-unsubscribe@kafka.apache.org

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