[ZBX-5379] Java Gateway doesn't start if old pidfile is present Created: 2012 Jul 30  Updated: 2017 May 30  Resolved: 2014 Feb 24

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Java gateway (J)
Affects Version/s: 2.0.1
Fix Version/s: 2.0.12rc1, 2.2.3rc1, 2.3.0

Type: Incident report Priority: Minor
Reporter: Matthias Ronge Assignee: Unassigned
Resolution: Fixed Votes: 4
Labels: startup
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

After a server crash, the server was automatically restarted. However, startup.sh didn't bring the Java Gateway back up again. It says "Zabbix Java Gateway is already running". It should start the service anyway replacing the stale pid file.

Shutdown.sh doesn't remove the pid file in case the process is not running either, it dies saying: .../shutdown.sh: line 8: kill: (20108) - No such process

So you cannot bring up the process with the means of these two scripts any more at all. You have to tease apart the script logic to find the pid file and manually remove it, but it's the case the system cannot stand up at it's own after a crash why I consider it as a bug.



 Comments   
Comment by Marc [ 2013 Mar 23 ]

I can confirm this - at least for release 2.0.5 RPMs taken from www.kodai74.net

Comment by Praveen Kumar [ 2013 Sep 26 ]

I can confirm this behavior in 2.0.8 too. The shutdown hook seems to be not doing much other than logging it...

Thread shutdownHook = new Thread()
{
public void run()
{
logger.info("Zabbix Java Gateway {} (revision {}) has stopped", GeneralInformation.VERSION, GeneralInformation.REVISION);
}
};

Runtime.getRuntime().addShutdownHook(shutdownHook);

Comment by Pat Turner [ 2013 Sep 26 ]

There is code that calls java.io.File.deleteOnExit() when pidFile is configured. But this only works on a graceful shutdown of the JVM.
Suggest code is added to the shutdown hook to explicitly delete the PID if its configured.

Comment by Aleksandrs Saveljevs [ 2014 Feb 21 ]

A shutdown hook above does not run when a Java process is killed with "kill -9 ...", but for "kill -15 ..." pidFile.deleteOnExit() is enough.

Pat, which scenario did you mean to fix by adding a shutdown hook that deletes the PID file?

Comment by Pat Turner [ 2014 Feb 21 ]

Hi Aleksandrs, I think you're right. Adding a shutdown hook won't help.
Perhaps the right solution is to make the startup script check if the PID file points to a running process. If there is no process running by that name, delete the file and proceed.

Comment by Aleksandrs Saveljevs [ 2014 Feb 24 ]

Stale PID file detection was added under ZBX-5558. Please see that issue for more details and the current progress.

Comment by Andris Zeila [ 2014 Mar 03 ]

Successfully tested

Comment by Aleksandrs Saveljevs [ 2014 Mar 05 ]

Fixed in pre-2.0.12 r43228, pre-2.2.3 r43229, and pre-2.3.0 (trunk) r43230.

Generated at Wed May 21 06:41:45 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.