lz4 / lz4-java

LZ4 compression for Java
Apache License 2.0
1.1k stars 253 forks source link

This is related to [#132](https://github.com/lz4/lz4-java/commit/08b3bff3491eafd5238c5adf79113e56f6821e82) #161

Closed lsingal closed 3 years ago

lsingal commented 4 years ago

We noticed an issue in our linux platform where we are not cleaning up the lib files after jvm crashes. I see that you made a fix to delete the lock files. Do you have plan to add functionality to delete the leftover *.so files.

odaira commented 4 years ago

Unfortunately, I don't think there is anything lz4-java can do for the leftover .so files caused by JVM crashes. At the loading time, lz4-java deletes any leftover .so files that are not accompanied by a corresponding .so.lck file. This logic is to handle the case #132. However, in case of a crash, both the .so and .so.lck files will be left behind, won't they? lz4-java cannot delete such a .so file, because it might be being used by another lz4-java running in another JVM.

Well, strictly speaking, if we assume the UNIX semantics of the file system, we might be able to delete such a .so file without affecting the process using it, but I don't think we can generalize it to all the systems JVM supports. Also, there would be a nasty race condition between the two JVMs using lz4-java.

The reason lz4-java uses the system-provided temporary directory to store the .so file is to tolerate cases like this. Even if there are leftover .so files in the temporary directory, they should not affect the other parts of the system.

odaira commented 3 years ago

Would you need any further clarification or have any suggestion?

odaira commented 3 years ago

Feel free to reopen this if you need further help.