Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329180

Summary: Slow server shutdown
Product: [RT] Jetty Reporter: Trygve Sanne Hardersen <trygve>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jetty-inbox
Version: unspecified   
Target Milestone: 7.1.x   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Shutdown patch for SelectorManager none

Description Trygve Sanne Hardersen CLA 2010-11-01 06:06:18 EDT
Build Identifier: 7.2.0.v20101020, trunk

I hit this problem with Apache Geronimo after they upgraded to Jetty 7.2.0.v20101020. The very slow shutdown of Geronimo was caused by it using too many threads, see GERONIMO-5668, but as Shawn Jiang from Geronimo has pointed out, Jetty will always use 1 second per acceptor thread to stop.

I have debugged this and found that the Closer used by the SelectSet in SelectorManager will never run. I don't know why, but at during shutdowns the doSelect() method of SelectSet is never called. Calling this method after adding the Closer to the list of changes results in the Closer actually being processed. I will attach a patch for this, though it might be better to solve the underlaying problem that prevents changes from being processed in the first place.

Reproducible: Always

Steps to Reproduce:
1. Start the server
2. Stop the server
Comment 1 Trygve Sanne Hardersen CLA 2010-11-01 06:09:37 EDT
Created attachment 182134 [details]
Shutdown patch for SelectorManager

Patch created against Jetty trunk revision 2459. I grant you this under that Apache License version 2.0.
Comment 2 Greg Wilkins CLA 2010-11-01 09:02:20 EDT
That code was changed to avoid a rare race condition of closing while the selection was in process.  It obviously has harmed the normal shutdown.

It's now been replaced by a simple spin check that waits for the the selector to exit before closing endpoints and the connector.

r2460
Comment 3 Trygve Sanne Hardersen CLA 2010-11-01 10:06:21 EDT
Many thanks, this makes the shutdown very fast.