embedded-postgres icon indicating copy to clipboard operation
embedded-postgres copied to clipboard

Embedded PostgreSQL fails to initialize but works after system restart

Open hongmiao-wu opened this issue 1 year ago • 3 comments

Exception in thread "main" java.lang.IllegalStateException: Process [/var/folders/dc/rmhssxvx42z7vcp49_md0_d80000gp/T/embedded-pg/PG-ba8cd9274b4f86c8aaab345231d9cd72/bin/initdb, -A, trust, -U, postgres, -D, /var/folders/dc/rmhssxvx42z7vcp49_md0_d80000gp/T/epg5263820244045919672, -E, UTF-8] failed
    at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres.system(EmbeddedPostgres.java:633)
    at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres.initdb(EmbeddedPostgres.java:250)
    at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres.<init>(EmbeddedPostgres.java:157)
    at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder.start(EmbeddedPostgres.java:584)
    at [email protected]/org.jabref.logic.search.PostgreServer.<init>(PostgreServer.java:27)
    at [email protected]/org.jabref.Launcher.main(Launcher.java:42)

Environment zonky.test:embedded-postgres:2.1.0 Application: JabRef OS: macOS 13.4 IntelliJ IDEA 2022.2.3 Java 23

hongmiao-wu avatar Feb 02 '25 21:02 hongmiao-wu

Hey @hongmiao-wu, thanks for the report.

In these situations, the best solution is to try running the PostgreSQL database manually using the following commands:

cd /var/folders/dc/rmhssxvx42z7vcp49_md0_d80000gp/T/embedded-pg/PG-ba8cd9274b4f86c8aaab345231d9cd72/bin
mkdir ./data && ./pg_ctl -D ./data start

The output should provide the Postgres database log, where the cause of the problem should be mentioned. If the database starts without issues, the problem is likely related to the permissions of the Java process that is trying to run the embedded Postgres.

You can check a similar issue here: https://github.com/zonkyio/embedded-postgres/issues/115

tomix26 avatar Feb 06 '25 15:02 tomix26

Unfortunately, it does not work.

First, it shows directory "data" is not a database cluster directory, then I use initdb -D ./data before starting.

Then PostgreSQL server starts successfully waiting for server to start....2025-02-22 10:33:45.465 CET [29417] LOG: starting PostgreSQL 14.15 (Homebrew) on aarch64-apple-darwin22.6.0, compiled by Apple clang version 15.0.0 (clang-1500.1.0.2.5), 64-bit

But the app(JabRef) I wanted to run still throws the same error I mentioned above `

hongmiao-wu avatar Feb 22 '25 09:02 hongmiao-wu

PostgreSQL 14.15 (Homebrew) - This doesn't look like binary files from this project. You need to use the ./ prefix when calling commands to ensure you're running files in the current directory, not global ones on the PATH. Currently, you're probably running the Homebrew version of PostgreSQL.

tomix26 avatar Feb 26 '25 20:02 tomix26

LInk to code: https://github.com/zonkyio/embedded-postgres/blob/4c3dde59d08d57d54f8d9845a1849a2399a75327/src/main/java/io/zonky/test/db/postgres/embedded/EmbeddedPostgres.java#L633

koppor avatar Apr 13 '25 05:04 koppor

Hey everyone, I'm getting a similar (if not the same?) error when trying to build. Restarting my machine didn't help either unfortunately.

Console Output:


21:59:50: Executing 'run'…

Starting Gradle Daemon...
Gradle Daemon started in 2 s 613 ms
> Task :buildSrc:compileJava NO-SOURCE
> Task :buildSrc:compileGroovy UP-TO-DATE
> Task :buildSrc:processResources NO-SOURCE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE

> Configure project :
Project : => 'org.jabref' Java module

> Task :generateBstGrammarSource UP-TO-DATE
> Task :generateCitaviSource UP-TO-DATE
> Task :generateLtwaGrammarSource UP-TO-DATE
> Task :generateSearchGrammarSource UP-TO-DATE
> Task :generateSource UP-TO-DATE
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :generateJournalListMV SKIPPED
> Task :downloadLtwaFile SKIPPED
> Task :generateLtwaListMV SKIPPED
> Task :jar UP-TO-DATE
> Task :mergeClasses SKIPPED

> Task :run
WARNING: Using incubator modules: jdk.incubator.vector
Messages are not initialized before accessing key: Display help on command line options
Exception in thread "main" java.lang.IllegalStateException: Process [C:\Users\felik\AppData\Local\Temp\embedded-pg\PG-5ac4f437d846f7a5fdd6304ef6d26686\bin\initdb.exe, -A, trust, -U, postgres, -D, C:\Users\username\AppData\Local\Temp\epg11801131462904900813, -E, UTF-8] failed
	at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres.system(EmbeddedPostgres.java:633)
	at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres.initdb(EmbeddedPostgres.java:250)
	at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres.<init>(EmbeddedPostgres.java:157)
	at [email protected]/io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder.start(EmbeddedPostgres.java:584)
	at [email protected]/org.jabref.logic.search.PostgreServer.<init>(PostgreServer.java:27)
	at [email protected]/org.jabref.Launcher.main(Launcher.java:42)

Specs: Windows 10 Home - Version 10.0.19045 Build 19045 IntelliJ IDEA 2024.3.5 Java 23

i tried to follow the JabRef-Setup very closely but encountered this at this step: https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-12-build.html

possibly noteworthy: I installed git and java on a seperate drive to my OS. I updated the path to git manually in the settings so i could pull from the forked repo.

edit: I stopped the build process and got this as console output: Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

iloveskittles82 avatar Apr 13 '25 20:04 iloveskittles82

found something: i ran the command by hand and got this popup

Image

grabbed the latest visual c++ redist and installed it. solved the issue!

https://learn.microsoft.com/de-de/cpp/windows/latest-supported-vc-redist?view=msvc-170

iloveskittles82 avatar Apr 15 '25 20:04 iloveskittles82

@iloveskittles82 Thank you for the info. I hope the original issue has also been addressed, so I'm closing this issue.

tomix26 avatar May 04 '25 14:05 tomix26