We have encountered problem, where tests using embedded-postgres sometimes start failing due postgres binary missing in the temp directory. Resolving these issues requires removing the embedded-pg directory under /var/folders/foo/bar/T/.
Investigating the problem lead to following conclusions
embedded-postgres extracts postgres binaries to folder named embedded-pg under directory returned by java.io.tmpdir system property. Marker file is used in this directory to mark if binaries have been extracted to the directory. If the marker file is present, no extraction is done
On my macOS system, java.io.tmpdir resolves to some /var/folders/foo/bar/T/ folder (where foo and bar are some environment dependent folder names)
By default, files in this location may be cleaned (removed) by the system if they are not accessed in 3 days.
Based on investigation on our failing cases, looks like that 3-day cleanup might (at least sometimes) clean the actual postgres-binaries, but not necessarily the marker file (maybe because the marker file is small?). That can lead to states, where marker file is present, but no actual binaries exists in the directory. That leads postgres start failing until the 'broken' temp directory is removed manually and binaries get extracted properly.
Unfortunately I don't know if there's any nice and simple fix for this. That linked page mentions cache directory at /var/folders/foo/bar/C which apparently should only get cleaned on reboot (and would probably clean everything at once), but I don't know if there's any nice and portable way of getting that location in Java.
We have encountered problem, where tests using embedded-postgres sometimes start failing due postgres binary missing in the temp directory. Resolving these issues requires removing the
embedded-pg
directory under/var/folders/foo/bar/T/
.Investigating the problem lead to following conclusions
embedded-pg
under directory returned byjava.io.tmpdir
system property. Marker file is used in this directory to mark if binaries have been extracted to the directory. If the marker file is present, no extraction is donejava.io.tmpdir
resolves to some/var/folders/foo/bar/T/
folder (wherefoo
andbar
are some environment dependent folder names)/T/
directory is the (user specific) temp directory andBased on investigation on our failing cases, looks like that 3-day cleanup might (at least sometimes) clean the actual postgres-binaries, but not necessarily the marker file (maybe because the marker file is small?). That can lead to states, where marker file is present, but no actual binaries exists in the directory. That leads postgres start failing until the 'broken' temp directory is removed manually and binaries get extracted properly.
Unfortunately I don't know if there's any nice and simple fix for this. That linked page mentions cache directory at
/var/folders/foo/bar/C
which apparently should only get cleaned on reboot (and would probably clean everything at once), but I don't know if there's any nice and portable way of getting that location in Java.