-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
PostgreSQL processes remain running after JabRef crashes or is forcefully terminated #12844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sigkill cannot be caught, but it would probably make sense to add a shutdown hook to ensure running instances are closed when sigterm occurs |
I have faced this too (noticed this yesterday). Every time I close and re-run JabRef (when running via IntelliJ), my task manager shows the old Postgres instance running. On running a new JabRef session again, a new Postgres session is also launched. After 5-6 trials, I was wondering why my system was lagging so much, then checked the task manager which had 6 running postgres instances. Edit - what I meant was another implication of this is lag during development. Edit - more details: Second run using IntelliJ reload: Now there are 2 background processes, 12 instances: All of them on CPU 00: And so on... |
https://adambien.blog/roller/abien/entry/sigterm_sigint_sigkill_and_java https://docs.oracle.com/en/java/javase/21/troubleshoot/handle-signals-and-exceptions.html |
Tried with: public class Launcher {
public static void main(String[] args) {
...
PostgreServer postgreServer = new PostgreServer();
Injector.setModelOrService(PostgreServer.class, postgreServer);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
if (postgreServer != null) {
try {
postgreServer.shutdown();
System.out.println("PostgreServer successfully shut down");
} catch (Exception e) {
System.err.println("Error shutting down PostgreServer: " + e.getMessage());
}
}
}));
JabRefGUI.setup(uiCommands, preferences, fileUpdateMonitor);
JabRefGUI.launch(JabRefGUI.class, args);
}
} Didn't work |
On checking logs, neither the try nor the catch is executed. On reading more, it appears that it's because there is no way to reliably execute code in case of a SIGKILL (the shutdownhook helps in case of SIGTERM and SIGINT). |
Sigkill is not catchable. That would be against its purpose
Subhramit Basu ***@***.***> schrieb am Fr., 28. März 2025,
19:42:
… Tried with:
...
Didn't work
On checking logs, neither the try nor the catch is executed. On reading
more, it appears that it's because there is no way to reliably execute code
in case of a SIGKILL (the shutdownhook helps in case of SIGTERM and SIGINT).
—
Reply to this email directly, view it on GitHub
<#12844 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACOFZESHHWCNLJHJILYGWL2WWJ2ZAVCNFSM6AAAAABZ7S5722VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRSGE2TMMRXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
[image: subhramit]*subhramit* left a comment (JabRef/jabref#12844)
<#12844 (comment)>
Tried with:
...
Didn't work
On checking logs, neither the try nor the catch is executed. On reading
more, it appears that it's because there is no way to reliably execute code
in case of a SIGKILL (the shutdownhook helps in case of SIGTERM and SIGINT).
—
Reply to this email directly, view it on GitHub
<#12844 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACOFZESHHWCNLJHJILYGWL2WWJ2ZAVCNFSM6AAAAABZ7S5722VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDONRSGE2TMMRXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hmm...so is this issue unsolvable from the perspective of shutdown it seems.. |
Idea for workaround: On start of new JabRef instance, old postgres (from JabRef) could be re-used (or killed) |
To me, this feels a bit like performing "magic" on the user's machine. Implementing such behavior is likely to be complex and error-prone.
This leads to a critical question: Which instance should JabRef attempt to reuse - or safely shut down? |
what if we do like this? 1.Record Postgres Metadata on Start When starting Embedded Postgres:
2.Check on New Start: On new Instance startup: |
…ination (Fix JabRef#12844) * Added logic to detect and clean up stale embedded PostgreSQL instances left behind by previous JabRef sessions. * Introduced PostgresProcessCleaner to safely shut down any orphaned PostgreSQL processes using PID-based detection. * Registered a shutdown hook in Launcher to ensure embedded PostgreSQL is properly terminated during normal or abrupt shutdown.
…ination (Fix JabRef#12844) * Added logic to detect and clean up stale embedded PostgreSQL instances left behind by previous JabRef sessions. * Introduced PostgresProcessCleaner to safely shut down any orphaned PostgreSQL processes using PID-based detection. * Registered a shutdown hook in Launcher to ensure embedded PostgreSQL is properly terminated during normal or abrupt shutdown. * Updated CHANGELOG.md
…ination (Fix JabRef#12844) * Added logic to detect and clean up stale embedded PostgreSQL instances left behind by previous JabRef sessions. * Introduced PostgresProcessCleaner to safely shut down any orphaned PostgreSQL processes using PID-based detection. * Registered a shutdown hook in Launcher to ensure embedded PostgreSQL is properly terminated during normal or abrupt shutdown.
…ination (Fix JabRef#12844) * Added logic to detect and clean up stale embedded PostgreSQL instances left behind by previous JabRef sessions. * Introduced PostgresProcessCleaner to safely shut down any orphaned PostgreSQL processes using PID-based detection. * Registered a shutdown hook in Launcher to ensure embedded PostgreSQL is properly terminated during normal or abrupt shutdown. * Updated CHANGELOG.md
…ination (Fix JabRef#12844) * Added logic to detect and clean up stale embedded PostgreSQL instances left behind by previous JabRef sessions. * Introduced PostgresProcessCleaner to safely shut down any orphaned PostgreSQL processes using PID-based detection. * Registered a shutdown hook in Launcher to ensure embedded PostgreSQL is properly terminated during normal or abrupt shutdown. * Updated CHANGELOG.md
…ination (Fix JabRef#12844) * style changes in PostgreProcessCleaner, Launcher
…ination (Fix JabRef#12844) * style changes in PostgreServer imports
…ination (Fix JabRef#12844) * Updated CHANGELOG.md
…ination (Fix JabRef#12844) * Modified PostgreProcessCleaner logic to fix windows os issue.
…ination (Fix JabRef#12844) * Used Path.of() instead of Paths.get() in PostgreProcessCleaner.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
…ination (Fix JabRef#12844) * Fix for trag-bot comments.
* Fix for trag-bot comments.
* Fix for trag-bot comments.
* Fix for trag-bot comments. * Created separate class PostgresMetadataWriter to follow SRP.
* Fix for trag-bot comments.
JabRef version
Latest development branch build (please note build date below)
Operating system
Windows
Details on version and operating system
Windows 10
Checked with the latest development build (copy version output from About dialog)
Steps to reproduce the behaviour
When JabRef crashes or is forcefully terminated (e.g., via
kill -9
or Task Manager), associated PostgreSQL processes often remain running. These orphaned processes continue to consume system resources unnecessarily.Steps to Reproduce
kill -9
or Task Manager).ps
on Linux/macOS.PostgreSQL Server
processes are still running.Expected Behavior
All PostgreSQL-related processes spawned by JabRef should terminate when JabRef is unexpectedly closed.
Actual Behavior
PostgreSQL processes persist after JabRef exits unexpectedly, leading to orphaned background processes.
Appendix
Screenshot
The text was updated successfully, but these errors were encountered: