MINOR: fix KafkaStreams#cleanUp(): should throw and fail for lock conflict#4713
MINOR: fix KafkaStreams#cleanUp(): should throw and fail for lock conflict#4713mjsax wants to merge 4 commits intoapache:trunkfrom
Conversation
|
lgtm |
There was a problem hiding this comment.
Could we add two more positive tests and see if we would reproduce the issue reported in KAFKA-6647?
-
in thread A: create the file, open the channel, grab the lock, and then release the lock, and close the channel; and then call
cleanupwhich should do the above again, and we should not expect any exception. -
in thread A: create the file, open the channel, grab the lock, and then release the lock, and close the channel; and then in a different thread B, call
cleanupwhich should do the above again, and we should not expect any exception.
guozhangwang
left a comment
There was a problem hiding this comment.
THanks @mjsax , the code change makes sense to me. I left a comment about whether we can reproduce the issue in KAFKA-6647.
|
Added more tests -- please have a detailed look if the tests cover all scenarios we want to cover and that I did not mess up the setup. Locally, the test passed. @gbloggs Could you check out this branch and run the test in your environment to see if they pass or fail there? It's hard to fix as long as we can't reproduce. |
|
I've tried running the changes in this PR and it seems to have made things worse. Streams will not start at all any more if KafKaStreams.cleanUp() is called before start(). Getting the following error: Caused by: org.apache.kafka.streams.errors.StreamsException: java.nio.file.DirectoryNotEmptyException: C:\tmp\kafka-streams\depot-query-stream-processor.local-dev\global If I add cleanUp() to the shutdownHook I get: |
|
Thanks for looking into that. It actually make sense that it is "worse" now because this PR fixes a swallowed exception, and also add the check for the global state directory. The good thing is, what we can reproduce the issue now reliably. In the impl, we still hold the What do others think? If we agree that this should be the right fix, I can add it to this PR. |
|
Isn't that what I did in #4702 ? |
I left a comment on the ticket about thinking carefully for moving the file lock: Because it is possible that two threads will conflict as they are holding on two different threads. A slightly different and more complicated approach if we want to keep the lock file in the same directory, is to delete other file / folders under that task id except the lock file: And depending on |
|
That's a good point @guozhangwang -- I originally thought, that this cannot happen because different instances need to be configured with different state directories -- but this is only true if a global store is used -- if no global store is use, the state directory can be shared and I agree that it would be problematic as you pointed out. |
|
I am having issues building Kafka clean from master. Keep getting: I have tried many different methods. I have IntelliJ with Scala but that fails. I am using Gradle 4.6, Scala 2.12.4, Java 8 on windows with gitbash/mingw64. I have tried setting SCALA_VERSION and tried updating the version in both kafka-run-class.bat & .sh and gradle.properties to 2.12.4. I was hoping to add some tests but cant get anything built. Anybody know how to resolve this? |
|
Not sure... Can you build on command line? Did you try to set |
|
I tried all the options including the -P. All on command line via git bash or the terminal in intellij. 😢 |
32d3ee1 to
d9e12ed
Compare
|
I just rebased this to make sure we can eventually merge it. Blocked via #5650 that should get merged first. |
d9e12ed to
f27f524
Compare
|
@guozhangwang Given that #8267 is merged, do we still need this PR? Or can we drop it? |
|
@mjsax I think we can drop it now. |
No description provided.