Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-17 Thread via GitHub


chia7712 merged PR #15733:
URL: https://github.com/apache/kafka/pull/15733


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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


soarez commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2060431133

   Thanks @chia7712 I'll have another look at this later today 


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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


chia7712 commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2060429559

   @soarez it would be great to get your reviews before merging 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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2059603416

   @chia7712 Thanks again for the review. I've implemented all of your 
suggested. Please let me know if you spot anything else I've missed.


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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567721679


##
core/src/main/scala/kafka/tools/StorageTool.scala:
##
@@ -440,8 +440,12 @@ object StorageTool extends Logging {
 "Use --ignore-formatted to ignore this directory and format the 
others.")
 }
 if (!copier.errorLogDirs().isEmpty) {
-  val firstLogDir = copier.errorLogDirs().iterator().next()
-  throw new TerseFailure(s"I/O error trying to read log directory 
$firstLogDir.")
+  copier.errorLogDirs().forEach(errorLogDir => {
+stream.println(s"I/O error trying to read log directory $errorLogDir. 
Ignoring...")
+  })
+  if(metaPropertiesEnsemble.emptyLogDirs().isEmpty) {
+throw new TerseFailure("No available log directories to format.")

Review Comment:
   Discussed below. I've now added the additional check to see if `logDirProps` 
is empty, and only throw this failure when this is also true. This is to 
prevent the format storage script from failing when the only remaining 
directories to be formatted are unavailable, but there is at least one 
directory already formatted, and the script is ran with `--ignore-formatted`.
   
   In this scenario, it should succeed as there is at least one successfully 
formatted directory.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567721679


##
core/src/main/scala/kafka/tools/StorageTool.scala:
##
@@ -440,8 +440,12 @@ object StorageTool extends Logging {
 "Use --ignore-formatted to ignore this directory and format the 
others.")
 }
 if (!copier.errorLogDirs().isEmpty) {
-  val firstLogDir = copier.errorLogDirs().iterator().next()
-  throw new TerseFailure(s"I/O error trying to read log directory 
$firstLogDir.")
+  copier.errorLogDirs().forEach(errorLogDir => {
+stream.println(s"I/O error trying to read log directory $errorLogDir. 
Ignoring...")
+  })
+  if(metaPropertiesEnsemble.emptyLogDirs().isEmpty) {
+throw new TerseFailure("No available log directories to format.")

Review Comment:
   Discussed below. I've now added the additional check to see if `logDirProps` 
is empty, and only throw this failure when this is also true. This is to 
prevent the format storage script from failing when then only remaining 
directories to be formatted are unavailable, but there is at least one 
directory already formatted, and the script is ran with `--ignore-formatted`.
   
   In this scenario, it should succeed as there is at least one successfully 
formatted directory.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567721679


##
core/src/main/scala/kafka/tools/StorageTool.scala:
##
@@ -440,8 +440,12 @@ object StorageTool extends Logging {
 "Use --ignore-formatted to ignore this directory and format the 
others.")
 }
 if (!copier.errorLogDirs().isEmpty) {
-  val firstLogDir = copier.errorLogDirs().iterator().next()
-  throw new TerseFailure(s"I/O error trying to read log directory 
$firstLogDir.")
+  copier.errorLogDirs().forEach(errorLogDir => {
+stream.println(s"I/O error trying to read log directory $errorLogDir. 
Ignoring...")
+  })
+  if(metaPropertiesEnsemble.emptyLogDirs().isEmpty) {
+throw new TerseFailure("No available log directories to format.")

Review Comment:
   Discussed below. I've now added the additional check to see if `logDirProps` 
is empty, and only throw this failure when this is also true. This is to 
prevent the format storage script from failing when there is at least one 
directory already formatted, and the only other non-formatted directories are 
unavailable, when it is ran with `--ignore-formatted`.
   
   In this scenario, it should succeed as there is at least one successfully 
formatted directory.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567721679


##
core/src/main/scala/kafka/tools/StorageTool.scala:
##
@@ -440,8 +440,12 @@ object StorageTool extends Logging {
 "Use --ignore-formatted to ignore this directory and format the 
others.")
 }
 if (!copier.errorLogDirs().isEmpty) {
-  val firstLogDir = copier.errorLogDirs().iterator().next()
-  throw new TerseFailure(s"I/O error trying to read log directory 
$firstLogDir.")
+  copier.errorLogDirs().forEach(errorLogDir => {
+stream.println(s"I/O error trying to read log directory $errorLogDir. 
Ignoring...")
+  })
+  if(metaPropertiesEnsemble.emptyLogDirs().isEmpty) {
+throw new TerseFailure("No available log directories to format.")

Review Comment:
   Discussed below. I've now added the additional check to see if `logDirProps` 
is empty, and only throw this failure when this is also true. This is to 
prevent the format storage script from failing when there is at least one 
directory already formatted, and the only other non-formatted directories are 
unavailable, when it is ran with `--ignore-formatted`.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567721679


##
core/src/main/scala/kafka/tools/StorageTool.scala:
##
@@ -440,8 +440,12 @@ object StorageTool extends Logging {
 "Use --ignore-formatted to ignore this directory and format the 
others.")
 }
 if (!copier.errorLogDirs().isEmpty) {
-  val firstLogDir = copier.errorLogDirs().iterator().next()
-  throw new TerseFailure(s"I/O error trying to read log directory 
$firstLogDir.")
+  copier.errorLogDirs().forEach(errorLogDir => {
+stream.println(s"I/O error trying to read log directory $errorLogDir. 
Ignoring...")
+  })
+  if(metaPropertiesEnsemble.emptyLogDirs().isEmpty) {
+throw new TerseFailure("No available log directories to format.")

Review Comment:
   Discussed below. I've now added the additional check to see if `logDirProps` 
is empty, and only throw this failure when this is also true. This is to 
prevent the format storage script from failing when there is at least one 
directory already formatted, and the only other directories are unavailable, 
when it is ran with `--ignore-formatted`.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567699963


##
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##
@@ -192,6 +192,66 @@ Found problem:
 } finally Utils.delete(tempDir)
   }
 
+  private def runFormatCommand(stream: ByteArrayOutputStream, directories: 
Seq[String]): Int = {
+val metaProperties = new MetaProperties.Builder().
+  setVersion(MetaPropertiesVersion.V1).
+  setClusterId("XcZZOzUqS4yHOjhMQB6JLQ").
+  setNodeId(2).
+  build()
+val bootstrapMetadata = 
StorageTool.buildBootstrapMetadata(MetadataVersion.latestTesting(), None, "test 
format command")
+StorageTool.formatCommand(new PrintStream(stream), directories, 
metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), 
ignoreFormatted = false)
+  }
+
+  @Test
+  def testFormatSucceedsIfAllDirectoriesAreAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val availableDir2 = TestUtils.tempDir()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
availableDir2.toString)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir2)))
+} finally {
+  Utils.delete(availableDir1)
+  Utils.delete(availableDir2)
+}
+  }
+
+  @Test
+  def testFormatSucceedsIfAtLeastOneDirectoryIsAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val unavailableDir1 = TestUtils.tempFile()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
unavailableDir1.toString)))
+  assertTrue(stream.toString().contains("I/O error trying to read log 
directory %s. Ignoring...".format(unavailableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertFalse(stream.toString().contains("Formatting 
%s".format(unavailableDir1)))
+} finally {
+  Utils.delete(availableDir1)
+  Utils.delete(unavailableDir1)
+}
+  }
+
+  @Test
+  def testFormatFailsIfAllDirectoriesAreUnavailable(): Unit = {
+val unavailableDir1 = TestUtils.tempFile()
+val unavailableDir2 = TestUtils.tempFile()
+try {
+  val stream = new ByteArrayOutputStream()
+  try {
+assertEquals(1, runFormatCommand(stream, Seq(unavailableDir1.toString, 
unavailableDir2.toString)))
+  } catch {
+case e: TerseFailure => assertEquals("No available log directories to 
format.", e.getMessage)

Review Comment:
   Much cleaner, I'll refactor this assertion too.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567694543


##
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##
@@ -192,6 +192,66 @@ Found problem:
 } finally Utils.delete(tempDir)
   }
 
+  private def runFormatCommand(stream: ByteArrayOutputStream, directories: 
Seq[String]): Int = {
+val metaProperties = new MetaProperties.Builder().
+  setVersion(MetaPropertiesVersion.V1).
+  setClusterId("XcZZOzUqS4yHOjhMQB6JLQ").
+  setNodeId(2).
+  build()
+val bootstrapMetadata = 
StorageTool.buildBootstrapMetadata(MetadataVersion.latestTesting(), None, "test 
format command")
+StorageTool.formatCommand(new PrintStream(stream), directories, 
metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), 
ignoreFormatted = false)
+  }
+
+  @Test
+  def testFormatSucceedsIfAllDirectoriesAreAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val availableDir2 = TestUtils.tempDir()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
availableDir2.toString)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir2)))
+} finally {
+  Utils.delete(availableDir1)
+  Utils.delete(availableDir2)
+}
+  }
+
+  @Test
+  def testFormatSucceedsIfAtLeastOneDirectoryIsAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val unavailableDir1 = TestUtils.tempFile()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
unavailableDir1.toString)))
+  assertTrue(stream.toString().contains("I/O error trying to read log 
directory %s. Ignoring...".format(unavailableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertFalse(stream.toString().contains("Formatting 
%s".format(unavailableDir1)))
+} finally {
+  Utils.delete(availableDir1)

Review Comment:
   Good spot! I'll remove these.



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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2059543825

   > Also, is my previous comment 
(https://github.com/apache/kafka/pull/15733#discussion_r1567431572) valid? the 
following test case is based on my comment, and it seems to me that should pass.
   
   @chia7712 You are indeed correct! Apologies, I was still running through the 
code to figure it out but came to the same conclusion. We should not fail in 
this scenario, I'll update the PR now.


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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


chia7712 commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567642200


##
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##
@@ -192,6 +192,66 @@ Found problem:
 } finally Utils.delete(tempDir)
   }
 
+  private def runFormatCommand(stream: ByteArrayOutputStream, directories: 
Seq[String]): Int = {
+val metaProperties = new MetaProperties.Builder().
+  setVersion(MetaPropertiesVersion.V1).
+  setClusterId("XcZZOzUqS4yHOjhMQB6JLQ").
+  setNodeId(2).
+  build()
+val bootstrapMetadata = 
StorageTool.buildBootstrapMetadata(MetadataVersion.latestTesting(), None, "test 
format command")
+StorageTool.formatCommand(new PrintStream(stream), directories, 
metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), 
ignoreFormatted = false)
+  }
+
+  @Test
+  def testFormatSucceedsIfAllDirectoriesAreAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val availableDir2 = TestUtils.tempDir()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
availableDir2.toString)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir2)))
+} finally {
+  Utils.delete(availableDir1)
+  Utils.delete(availableDir2)
+}
+  }
+
+  @Test
+  def testFormatSucceedsIfAtLeastOneDirectoryIsAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val unavailableDir1 = TestUtils.tempFile()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
unavailableDir1.toString)))
+  assertTrue(stream.toString().contains("I/O error trying to read log 
directory %s. Ignoring...".format(unavailableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertFalse(stream.toString().contains("Formatting 
%s".format(unavailableDir1)))
+} finally {
+  Utils.delete(availableDir1)

Review Comment:
   the file created by `TestUtils.tempFile()` will be delete on jvm exit 
(https://github.com/apache/kafka/blob/trunk/clients/src/test/java/org/apache/kafka/test/TestUtils.java#L198),
 so we don't need to call delete here



##
core/src/test/scala/unit/kafka/tools/StorageToolTest.scala:
##
@@ -192,6 +192,66 @@ Found problem:
 } finally Utils.delete(tempDir)
   }
 
+  private def runFormatCommand(stream: ByteArrayOutputStream, directories: 
Seq[String]): Int = {
+val metaProperties = new MetaProperties.Builder().
+  setVersion(MetaPropertiesVersion.V1).
+  setClusterId("XcZZOzUqS4yHOjhMQB6JLQ").
+  setNodeId(2).
+  build()
+val bootstrapMetadata = 
StorageTool.buildBootstrapMetadata(MetadataVersion.latestTesting(), None, "test 
format command")
+StorageTool.formatCommand(new PrintStream(stream), directories, 
metaProperties, bootstrapMetadata, MetadataVersion.latestTesting(), 
ignoreFormatted = false)
+  }
+
+  @Test
+  def testFormatSucceedsIfAllDirectoriesAreAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val availableDir2 = TestUtils.tempDir()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
availableDir2.toString)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir2)))
+} finally {
+  Utils.delete(availableDir1)
+  Utils.delete(availableDir2)
+}
+  }
+
+  @Test
+  def testFormatSucceedsIfAtLeastOneDirectoryIsAvailable(): Unit = {
+val availableDir1 = TestUtils.tempDir()
+val unavailableDir1 = TestUtils.tempFile()
+try {
+  val stream = new ByteArrayOutputStream()
+  assertEquals(0, runFormatCommand(stream, Seq(availableDir1.toString, 
unavailableDir1.toString)))
+  assertTrue(stream.toString().contains("I/O error trying to read log 
directory %s. Ignoring...".format(unavailableDir1)))
+  assertTrue(stream.toString().contains("Formatting 
%s".format(availableDir1)))
+  assertFalse(stream.toString().contains("Formatting 
%s".format(unavailableDir1)))
+} finally {
+  Utils.delete(availableDir1)
+  Utils.delete(unavailableDir1)
+}
+  }
+
+  @Test
+  def testFormatFailsIfAllDirectoriesAreUnavailable(): Unit = {
+val unavailableDir1 = TestUtils.tempFile()
+val unavailableDir2 = TestUtils.tempFile()
+try {
+  val stream = new ByteArrayOutputStream()
+  try {
+assertEquals(1, runFormatCommand(stream, Seq(unavailableDir1.toString, 
unavailableDir2.toString)))
+  } catch {
+case e: TerseFailure => assertEquals("No available log directories to 
format.", e.getMessage)

Review Comment:
   it seems 

Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2059463882

   > It seems the three new tests have a lot in common:
   >
   > the setup of MetaProperties, ByteArrayOutputStream and BootstrapMetadata
   the invocation of command formatCommand
   Is it worth extracting that into a utility method?
   
   @soarez I've refactored the tests to use a new utility method which prepares 
and invokes the format storage command, taking only the directories to format 
and the stream to use, which has cleaned up the common setup in the tests.


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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


chia7712 commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2059291065

   > LogManager can accept failed directories in startup. That method is a bit 
confusing, but if you look a bit below the line you pointed to, the exception 
is caught, the fact the directory is failed is processed, and the directory is 
not added to liveLogDirs.
   
   thanks for sharing this to me. happy to learn 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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


soarez commented on PR #15733:
URL: https://github.com/apache/kafka/pull/15733#issuecomment-2059274214

   @chia7712 Thanks for reviewing this.
   
   > It seems LogManager can't accept failed directories in startup, right?
   
   LogManager can accept failed directories in startup. That method is a bit 
confusing, but if you look a bit below the line you pointed to, the exception 
is caught, the fact the directory is failed is processed, and the directory is 
not added to `liveLogDirs`.
   
   
https://github.com/apache/kafka/blob/fccd7fec666d6570758e0b7891771099240ceee8/core/src/main/scala/kafka/log/LogManager.scala#L201-L204


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



Re: [PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


chia7712 commented on code in PR #15733:
URL: https://github.com/apache/kafka/pull/15733#discussion_r1567431572


##
core/src/main/scala/kafka/tools/StorageTool.scala:
##
@@ -440,8 +440,12 @@ object StorageTool extends Logging {
 "Use --ignore-formatted to ignore this directory and format the 
others.")
 }
 if (!copier.errorLogDirs().isEmpty) {
-  val firstLogDir = copier.errorLogDirs().iterator().next()
-  throw new TerseFailure(s"I/O error trying to read log directory 
$firstLogDir.")
+  copier.errorLogDirs().forEach(errorLogDir => {
+stream.println(s"I/O error trying to read log directory $errorLogDir. 
Ignoring...")
+  })
+  if(metaPropertiesEnsemble.emptyLogDirs().isEmpty) {
+throw new TerseFailure("No available log directories to format.")

Review Comment:
   Do we need to check `logDirProps` before throwing this exception?



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



[PR] KAFKA-16363: Storage tool crashes if dir is unavailable [kafka]

2024-04-16 Thread via GitHub


mwesterby opened a new pull request, #15733:
URL: https://github.com/apache/kafka/pull/15733

   Prevents the storage tool from crashing when some of the directories are 
unavailable, but others are still available and have not yet been formatted.
   
   Should all directories be unavailable however, then the tool will fail.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


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