Merge lp:~jamesodhunt/upstart/bug-1227212 into lp:upstart
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 1534 | ||||
Proposed branch: | lp:~jamesodhunt/upstart/bug-1227212 | ||||
Merge into: | lp:upstart | ||||
Diff against target: |
568 lines (+321/-34) 8 files modified
ChangeLog (+35/-0) init/event.c (+20/-0) init/job_process.c (+14/-3) init/quiesce.c (+176/-23) init/quiesce.h (+3/-0) test/test_util_common.c (+24/-5) test/test_util_common.h (+4/-1) util/tests/test_initctl.c (+45/-2) |
||||
To merge this branch: | bzr merge lp:~jamesodhunt/upstart/bug-1227212 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dimitri John Ledkov | Approve | ||
Review via email: mp+187844@code.launchpad.net |
Description of the change
* init/event.c: event_pending_
instances have finished to speed session shutdown.
* init/job_process.c: job_process_
instances with associated pids to avoid abstract jobs confusing the
shutdown.
* init/quiesce.c:
- quiesce(): Optimise session shutdown
- Skip wait phase if no jobs care about the 'session-end' event
(LP: #1227212).
- Stop already running instances if other jobs care about
'session-end' to allow the already-running jobs to shut down in
parallel with the newly-started session-end jobs.
- quiesce_
- Simplify logic.
- Improve wait phase checks to detect earliest time to finalise.
- quiesce_finalise(): Display time to shutdown.
- quiesce_complete(): New function to force final shutdown phase.
- quiesce_
'start on' contains a particular event.
- quiesce_
* test/test_
- _start_upstart(): Call get_upstart_
UPSTART_BINARY define.
- start_upstart_
needed by a test.
- get_upstart_
- file_exists(): New helper function.
* test/test_
* util/tests/
- New test "session shutdown: one long-running job which starts on
startup".
- Adjusted expected shutdown times.
-------
Expected behaviour:
= Common Case =
- If no jobs 'start on session-end', shutdown is "immediate". This is the common case.
=> Shutdown time: 1 second.
= Jobs Specifying 'session-end' =
- If any job specifies 'start on session-end' (no standard jobs do):
- The shutdown will stop all running job instances.
- The shutdown will allow session-end jobs to run as long as they complete within 5 seconds.
=> Shutdown time: 5 seconds.
= Jobs Specifying 'session-end' and blocking SIGTERM =
- If no jobs specify 'start on session-end' but some jobs block SIGTERM:
=> Shutdown time: 5 seconds.
- If any job specifies 'start on session-end' and blocks SIGTERM (but
not other jobs block SIGTERM):
- The shutdown will wait for up to 5 seconds for the jobs to run.
- The shutdown will then signal them with SIGTERM and wait for up to a further 5 seconds before sending SIGKILL.
=> Shutdown time: 5+5 = 10 seconds.
- If any job specifies 'start on session-end' and blocks SIGTERM *and* other non-session-end jobs
running at shutdown also block SIGTERM:
=> Shutdown time: 5+5 = 10 seconds (*).
= Jobs with Long-Running pre-start stanzas =
Job that have long-running pre-start stanzas could also slow down the session shutdown since changing their state will take the duration of the time to execute the pre-start stanza. One of the standard session jobs fell into this category ('logrotate') but has now been fixed.
Note that the SIGTERM case is pathological and should be surmountable using the 'kill signal' stanza (see init(5) and
http://
(*) - Not 15 seconds, since the shutdown will send SIGTERM to all non-session-end jobs such that their kill timer runs in parallel with the session-end jobs wait time.