Repository: kafka Updated Branches: refs/heads/trunk 181df80dc -> 66ecf3f08
KAFKA-1860: Fix issue that file system errors are not detected unless Kafka tries to write. When the disk (raid with caches dir) dies on a Kafka broker, typically the filesystem gets mounted into read-only mode, and hence when Kafka tries to read the disk, they'll get a FileNotFoundException with the read-only errno set (EROFS). However, as long as there is no produce request received, hence no writes attempted on the disks, Kafka will not exit on such FATAL error and keep on throwing exception : java.io.FileNotFoundException In this case, the JVM should stop if the underlying file system goes in to Read only mode. Author: MayureshGharat <[email protected]> Reviewers: Lin Dong, Gwen Shapira, Ismael Juma, Guozhang Wang Closes #698 from MayureshGharat/KAFKA-1860 Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/66ecf3f0 Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/66ecf3f0 Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/66ecf3f0 Branch: refs/heads/trunk Commit: 66ecf3f08d7ce19c45fc16bf679df46cab349a8a Parents: 181df80 Author: Mayuresh Gharat <[email protected]> Authored: Mon Feb 1 14:41:21 2016 -0800 Committer: Guozhang Wang <[email protected]> Committed: Mon Feb 1 14:41:21 2016 -0800 ---------------------------------------------------------------------- core/src/main/scala/kafka/server/OffsetCheckpoint.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/66ecf3f0/core/src/main/scala/kafka/server/OffsetCheckpoint.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/kafka/server/OffsetCheckpoint.scala b/core/src/main/scala/kafka/server/OffsetCheckpoint.scala index 77f283c..df46336 100644 --- a/core/src/main/scala/kafka/server/OffsetCheckpoint.scala +++ b/core/src/main/scala/kafka/server/OffsetCheckpoint.scala @@ -16,7 +16,7 @@ */ package kafka.server -import java.nio.file.Paths +import java.nio.file.{FileSystems, Paths} import java.util.regex.Pattern import org.apache.kafka.common.utils.Utils @@ -60,6 +60,13 @@ class OffsetCheckpoint(val file: File) extends Logging { writer.flush() fileOutputStream.getFD().sync() + } catch { + case e: FileNotFoundException => + if (FileSystems.getDefault.isReadOnly) { + fatal("Halting writes to offset checkpoint file because the underlying file system is inaccessible : ", e) + Runtime.getRuntime.halt(1) + } + throw e } finally { writer.close() }
