zonkyio / embedded-postgres

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

Problem with macOS temp directory handling (startups fail with missing postgres binary) #50

Closed jpsyri closed 3 years ago

jpsyri commented 3 years ago

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

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.

tomix26 commented 3 years ago

Thanks for the comprehensive description of the problem 👍