apoorvmittal10 commented on code in PR #17957:
URL: https://github.com/apache/kafka/pull/17957#discussion_r1866539003


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -380,6 +380,14 @@ public CompletableFuture<Void> maybeInitialize() {
 
             // Update state to initializing to avoid any concurrent requests 
to be processed.
             partitionState = SharePartitionState.INITIALIZING;
+        } catch (Exception e) {
+            log.error("Failed to initialize the share partition: {}-{}", 
groupId, topicIdPartition, e);
+            completeInitializationWithException(future, e);
+            return future;
+        } finally {
+            lock.writeLock().unlock();
+        }
+        try {

Review Comment:
   >We need this try in case we have persister.readState throw any exceptions
   
   Hmmm, I was more in line with to have the try block when lock is required 
and not have `persister.readState/persister.writeState` in the try block as 
persister should return the completable future with exception, if failed, and 
should never throw an exception directly. The javadoc of persister do not 
specify throwing any exceptions directly.
   
   >We even have a test case testMaybeInitializeWithReadException in 
SharePartitionTest that verifies this behaviour
   
   We can change the expectation of the test in the 2nd case of the test. Also 
we should see the exception is being handled at top level if this happens but 
we can't write entire code in try/catch.
   



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