Open mariankassovic opened 7 years ago
Thanks for reporting the issue. Unfortunately I can't provide support for the Windows platform. If you know how to fix the problem, please send a PR and I'll be happy to accept it.
I have only a small improvement - add awaitShutdown() call in EphemeralKafkaBroker method stopBroker before trying to delete Kafka log directory.
private void stopBroker() {
try {
if (kafkaServer != null) {
LOGGER.info("Shutting down Kafka Server");
kafkaServer.shutdown();
kafkaServer.awaitShutdown();
}
Unfortunately it does not solve the problem completely, since it looks like Kafka does not close topic properly on shutdown :-( Tests run green, but temp folder clean-up is failing...
Yes, I remember reading that Windows creates exclusive locks on files whereas Unix-like systems don't. This is probably something to do with that. I'll mark this as up-for-grabs so that someone with knowledge of Windows (and access to a Windows machine) can pick it up and work on it.
I'm also suffering from this:
2018-03-22 13:36:28.080 ERROR 5828 --- [ Thread-8] org.apache.kafka.test.TestUtils : Error deleting C:\Users\X\AppData\Local\Temp\kafka-5223924343707963804
java.nio.file.FileSystemException: C:\Users\X\AppData\Local\Temp\kafka-5223924343707963804\version-2\log.1: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86) ~[na:1.8.0_144]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[na:1.8.0_144]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[na:1.8.0_144]
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) ~[na:1.8.0_144]
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) ~[na:1.8.0_144]
at java.nio.file.Files.delete(Files.java:1126) ~[na:1.8.0_144]
at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:630) ~[kafka-clients-1.0.1.jar:na]
at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
at java.nio.file.Files.walkFileTree(Files.java:2670) ~[na:1.8.0_144]
at java.nio.file.Files.walkFileTree(Files.java:2742) ~[na:1.8.0_144]
at org.apache.kafka.common.utils.Utils.delete(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:184) ~[kafka-clients-1.0.1-test.jar:na]
2018-03-22 13:36:28.091 ERROR 5828 --- [ Thread-11] org.apache.kafka.test.TestUtils : Error deleting C:\Users\X\AppData\Local\Temp\kafka-5049848438722543295
java.nio.file.FileSystemException: C:\Users\X\AppData\Local\Temp\kafka-5049848438722543295\version-2\log.1: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86) ~[na:1.8.0_144]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97) ~[na:1.8.0_144]
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102) ~[na:1.8.0_144]
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269) ~[na:1.8.0_144]
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103) ~[na:1.8.0_144]
at java.nio.file.Files.delete(Files.java:1126) ~[na:1.8.0_144]
at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:630) ~[kafka-clients-1.0.1.jar:na]
at org.apache.kafka.common.utils.Utils$1.visitFile(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
at java.nio.file.Files.walkFileTree(Files.java:2670) ~[na:1.8.0_144]
at java.nio.file.Files.walkFileTree(Files.java:2742) ~[na:1.8.0_144]
at org.apache.kafka.common.utils.Utils.delete(Utils.java:619) ~[kafka-clients-1.0.1.jar:na]
at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:184) ~[kafka-clients-1.0.1-test.jar:na]
Also experiencing this issue
2018-04-03 15:56:25.652 ERROR 4816 --- [ Thread-4] org.apache.kafka.test.TestUtils : Error deleting C:\Users\stewalia\AppData\Local\Temp\kafka-7101259950782722212
java.nio.file.FileSystemException: C:\Users\stewalia\AppData\Local\Temp\kafka-7101259950782722212\product-0\00000000000000000000.index: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
at java.nio.file.Files.delete(Files.java:1126)
at org.apache.kafka.common.utils.Utils$2.visitFile(Utils.java:591)
at org.apache.kafka.common.utils.Utils$2.visitFile(Utils.java:580)
at java.nio.file.Files.walkFileTree(Files.java:2670)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at org.apache.kafka.common.utils.Utils.delete(Utils.java:580)
at org.apache.kafka.test.TestUtils$1.run(TestUtils.java:182)
Hi
We were facing the same issue. However it is a no blocking issue (in our case), the real issue may when we use Helper.produceStrings
in this.produce() ... it should be better to call .get() to be sure that message was really produced (sync)
public <K, V> void produce(String topic, KafkaProducer<K, V> producer, Map<K, V> data) { data.forEach((k, v) -> { producer.send(new ProducerRecord(topic, k, v)); }); producer.flush(); }
protected <K, V> void produce(String topic, KafkaProducer<K, V> producer, Map<K, V> data) {
data.forEach((k, v) -> {
try {
producer.send(new ProducerRecord(topic, k, v)).get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
});
producer.flush();
}
Could you please give more details about how do you implement your tests? which methods, classes do you use to consume / produce messages?
faced the same issue, as a workaround added the following to a Gradle clean task:
import org.apache.tools.ant.taskdefs.condition.Os
clean {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
def tempDir = System.getProperties().getProperty("java.io.tmpdir")
def ft = fileTree(tempDir) {
include 'kafka-*'
exclude 'kafka-logs'
}
ft.visit {
FileVisitDetails fvd ->
println "deleted kafka temp folder: " + tempDir + fvd.name
delete fvd.file
}
}
}
This problem prevents me from upgrading as well. My error message is slightly different however
ERROR kafka.server.BrokerMetadataCheckpoint - Failed to write meta.properties due to
java.nio.file.AccessDeniedException: C:\Users\Maji\AppData\Local\Temp\kafka_junit16787608145441309316
At least in my case, the issue seems to be with Kafka itself https://issues.apache.org/jira/browse/KAFKA-13390 = https://github.com/apache/kafka/pull/11426
Running JUnit EphemeralKafkaBrokerTest on Windows is failing:
There has to be some issue with statitcs since next run ends differenly
This might not be obvious on Linux platform. I suppose that there is some resource leak that keeps directory file handle open.