Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Fix one cause of zombie buckd processes
Browse files Browse the repository at this point in the history
Summary:
We've gotten reports of multiple `buckd` processes being created for
a single root, and `buck kill` doesn't make the extras go away. I've
been investigating the prevalence of this problem, and along the way
I found one cause of it. The comment in the code says the rest.

Reviewed By: styurin

fbshipit-source-id: 4a13247d7d
  • Loading branch information
jkeljo authored and facebook-github-bot committed Jan 10, 2019
1 parent a3d1413 commit 5c5eb4e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/com/facebook/buck/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2277,13 +2277,26 @@ public static void main(String[] args) {
if (socketPath.startsWith("local:")) {
socketPath = socketPath.substring("local:".length());
}
SecurityManager securityManager = System.getSecurityManager();
NGServer server =
new NGServer(
new NGListeningAddress(socketPath),
1, // store only 1 NGSession in a pool to avoid excessive memory usage
heartbeatTimeout);
daemonKillers = new DaemonKillers(housekeepingExecutorService, server, Paths.get(socketPath));
server.run();
try {
server.run();
} catch (RuntimeException e) {
// server.run() might throw (for example, if this process loses the race with another
// process to become the daemon for a given Buck root). Letting the exception go would
// kill this thread, but other non-daemon threads have already been started and we haven't
// yet installed the unhandled exception handler that would call System.exit, so this
// process would live forever as a zombie. We catch the exception, re-instate the original
// security manager (because NailGun has replaced it with one that blocks System.exit, and
// doesn't restore the original if an exception occurs), and exit.
System.setSecurityManager(securityManager);
LOG.error(e, "Exception thrown in NailGun server.");
}
System.exit(0);
}

Expand Down

0 comments on commit 5c5eb4e

Please sign in to comment.