Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Slow shutdown of unix socket in jetty 9.4.0.RC0

Hiya,

I'm using jetty for local RPC over unix sockets (using Avro), and I started encountering an unexplained 30-second wait on shutdown on Ubuntu 14.04. My dev machine is OS X and everything works smoothly there. JStack showed me that the server is blocking on the call to poll() on the unix socket's channel, and shutdown takes exactly 30 seconds every time, even if the machine is under load, which implies there is some 30-second timeout.

This isn't critical for our run-time behavior but adds a ton of time to our tests, so any help would be appreciated.

Since avro is a huge machine with many moving parts I created a smaller replication that has very little in it and points even more strongly to the unix socket code being the culprit:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.unixsocket.UnixSocketConnector;

public class Main {
private static Logger LOG = Logger.getLogger(HttpServer2.class.getSimpleName());

public static class TrivialServlet extends HttpServlet {

public TrivialServlet() {
super();
}

protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doPost(req, res);
}

protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");

PrintWriter writer = res.getWriter();
writer.println("<html>");
writer.println("<head><title>Hello World Servlet</title></head>");
writer.println("<body>Hello World! How are you doing?</body>");
writer.println("</html>");
writer.close();
}
}

public static void main(String[] args) throws Exception {
Server server = new Server();

UnixSocketConnector connector = new UnixSocketConnector(server);
connector.setAcceptQueueSize(128);
connector.setUnixSocket("test.sock");
server.addConnector(connector);

ServletContextHandler handler = new ServletContextHandler(null, "/");
handler.setServer(server);
handler.addServlet(new ServletHolder(new TrivialServlet()), "/*");
server.setHandler(handler);

LOG.info("created server");
server.start();
LOG.info("started, now stopping");
server.stop();
LOG.info("closed");
}
}


Back to the top