Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329180 - Slow server shutdown
Summary: Slow server shutdown
Status: RESOLVED FIXED
Alias: None
Product: Jetty
Classification: RT
Component: server (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 7.1.x   Edit
Assignee: Greg Wilkins CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-01 06:06 EDT by Trygve Sanne Hardersen CLA
Modified: 2010-11-01 10:06 EDT (History)
1 user (show)

See Also:


Attachments
Shutdown patch for SelectorManager (720 bytes, patch)
2010-11-01 06:09 EDT, Trygve Sanne Hardersen CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.