lqjack commented on a change in pull request #9596:
URL: https://github.com/apache/kafka/pull/9596#discussion_r524053292



##########
File path: core/src/test/scala/unit/kafka/log/LogManagerTest.scala
##########
@@ -83,6 +87,51 @@ class LogManagerTest {
     log.appendAsLeader(TestUtils.singletonRecords("test".getBytes()), 
leaderEpoch = 0)
   }
 
+  /**
+   * Tests that all internal futures are completed before 
LogManager.shutdown() returns to the
+   * caller during error situations.
+   */
+  @Test
+  def testHandlingExceptionsDuringShutdown(): Unit = {
+    logManager.shutdown()
+
+    // We create two directories logDir1 and logDir2 to help effectively test 
error handling
+    // during LogManager.shutdown().
+    val logDir1 = TestUtils.tempDir()
+    val logDir2 = TestUtils.tempDir()
+    logManager = createLogManager(Seq(logDir1, logDir2))
+    assertEquals(2, logManager.liveLogDirs.size)
+    logManager.startup()
+
+    val log1 = logManager.getOrCreateLog(new TopicPartition(name, 0), () => 
logConfig)
+    val log2 = logManager.getOrCreateLog(new TopicPartition(name, 1), () => 
logConfig)
+
+    val logFile1 = new File(logDir1, name + "-0")
+    assertTrue(logFile1.exists)
+    val logFile2 = new File(logDir2, name + "-1")
+    assertTrue(logFile2.exists)
+
+    log1.appendAsLeader(TestUtils.singletonRecords("test1".getBytes()), 
leaderEpoch = 0)
+    log1.takeProducerSnapshot()
+    log1.appendAsLeader(TestUtils.singletonRecords("test1".getBytes()), 
leaderEpoch = 0)
+
+    log2.appendAsLeader(TestUtils.singletonRecords("test2".getBytes()), 
leaderEpoch = 0)
+    log2.takeProducerSnapshot()
+    log2.appendAsLeader(TestUtils.singletonRecords("test2".getBytes()), 
leaderEpoch = 0)
+
+    // This should cause log1.close() to fail during LogManger shutdown 
sequence.
+    FileUtils.deleteDirectory(logFile1)

Review comment:
       If the end user delete the log files Manually , the server cannot be 
stopped. and The cannot startup it again? so in this case ,how do they resolve 
it ?  




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

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


Reply via email to