zonkyio / embedded-postgres

Java embedded PostgreSQL component for testing
Apache License 2.0
344 stars 43 forks source link

OverlappingFileLockException #63

Closed taig closed 2 years ago

taig commented 3 years ago

I'm seeing this exception pop up in my CI integration tests rather frequently. I assume it is related to the concurrent execution of the test framework. For me, it is sufficient to simply catch and retry, but perhaps you can find a proper way to handle this:

Caused by: java.nio.channels.OverlappingFileLockException
    at java.base/sun.nio.ch.FileLockTable.checkList(FileLockTable.java:229)
    at java.base/sun.nio.ch.FileLockTable.add(FileLockTable.java:123)
    at java.base/sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1154)
    at java.base/java.nio.channels.FileChannel.tryLock(FileChannel.java:1165)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.prepareBinaries(EmbeddedPostgres.java:810)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.<init>(EmbeddedPostgres.java:133)
    at io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder.start(EmbeddedPostgres.java:583)
    ...
tomix26 commented 3 years ago

Thanks for the report, I'll take a look at it.

tomix26 commented 3 years ago

I am sorry for the late response. However, I need to ask if you are using SBT server or custom classloader or something similar that could cause the same class to be loaded multiple times in the same Java virtual machine?

taig commented 3 years ago

Yes, I'm using this library with sbt. As far as I know, sbt server is not involved when running sbt in batch mode on CI, but the issue occurs in this environment nonetheless. But still, sbt does a lot of classpath magic behind the scenes that I occasionally run into. So if the reported issue might be caused by classloader issues, I'm still convinced that sbt is to blame here.

tomix26 commented 2 years ago

Sorry, SBT is not supported at the moment. There are some other problems regarding classpath magic and I am not familiar enough with it to be able to solve them. For instance this one: https://github.com/zonkyio/embedded-postgres/pull/65