/admin?op=exit gracefully shuts down a running
MDEX Engine.
The
/admin?op=exit command has two formats:
- The base version does not
use the
timelimit option.
- The timeout version uses the
timelimit option.
Using the base version
The format of the base version is:
/admin?op=exit
The
exit operation works as follows:
- Any new non-admin request
will get an HTTP response code 503 (Service Unavailable).
- Any in-progress request
will finish normally (including updates).
- The MDEX Engine will wait
to exit until the following conditions have been met:
- All requests have
finished (including updates).
- All background merging
has been completed.
The
exit operation's output to the browser looks similar
to the following:
Dgraph admin, OK
Dgraph shutting down at Thu Feb 17 13:12:54 2011
The command also writes shutdown information to the Dgraph error log,
as in this example:
Shutdown request with received at Thu Feb 17 13:12:54 2011.
Shutdown will complete when all outstanding jobs are complete.
All dgraph transactions completed at Thu Feb 17 13:12:54 2011, exiting normally (pid=4128)
The base
exit operation is the recommended way to shut down the
MDEX Engine because it gracefully completes all transactions and exits cleanly.
However, note that because the MDEX Engine waits until all background merging
has completed, the shutdown process could potentially take several hours if the
request occurs during a major merge. Therefore, if the speed of the shutdown is
more important than the completing a merge, you should consider using the
timelimit option to set a time limit for the shutdown
operation.
Using the timelimit option
The timeout version lets you specify a time limit, in seconds, of the
shutdown procedure. The format of the timeout version is:
/admin?op=exit&timelimit=seconds
where
seconds is a positive integer.
This example uses a time limit of 30 seconds:
/admin?op=exit&timelimit=30
The
exit&timelimit operation works as follows:
- A time limit of 0 (zero)
will shut down the MDEX Engine immediately.
- Any queries still in
progress when the time limit is reached will not return a result to the client
(i.e., the client will observe a closed connection).
- Any queries still in
progress when the time limit is reached will not be logged in the Dgraph log.
- Any updates still in
progress when the time limit is reached will not be applied.
- Any background merges
still in progress when the time limit is reached will be aborted at the end of
the timeout.
- The number of in-progress
queries is written to the Dgraph error log just before exiting, along with a
message stating that the shutdown time limit was reached.
Issuing an
exit command with a time limit ensures that the MDEX
Engine shuts down within that time limit, regardless of prior or following
exit queries (i.e.,
exit commands with a time limit can only shorten the
MDEX Engine's time to live). These examples demonstrate what happens when
successive
exit commands are issued:
- If
exit&timelimit=30 is issued and 10 seconds later
exit&timelimit=0 is issued, the MDEX Engine will
exit immediately when the second request is issued (if it hasn't already
exited).
- If
exit&timelimit=30 is issued and 10 seconds later
exit&timelimit=5 is issued, the MDEX Engine will
exit 5 seconds after the second request, or when all queries are drained
(whichever comes first).
- If
exit&timelimit=30 is issued and 10 seconds later
exit&timelimit=30 is issued, the MDEX Engine
will exit 30 seconds after the first request, or when all queries are drained
(whichever comes first).
- If
exit&timelimit=30 is issued and 10 seconds later
the base
exit command is issued, the MDEX Engine will exit 30
seconds after the first request, or when all queries are drained (whichever
comes first).
- If
exit is issued and 10 seconds later
exit&timelimit=30 is issued, the MDEX Engine
will exit 30 seconds after the second request, or when all queries are drained
(whichever comes first).
An
exit&timelimit=30 operation's output to the
browser looks like this:
Dgraph admin, OK
Dgraph shutting down within 30 seconds at Thu Feb 17 14:09:38 2011
The command also writes shutdown information to the Dgraph error log,
as in this example for an
exit&timelimit=30 command:
Shutdown request with time limit of 30 seconds received at Thu Feb 17 14:09:38 2011.
Shutdown will complete when all outstanding jobs are complete, or within 30 seconds, whichever happens earlier.
All dgraph transactions completed at Thu Feb 17 13:12:54 2011, exiting normally (pid=4128)
If command were for an immediate shutdown
(
exit&timelimit=0) and queries were still in progress, the
Dgraph error log would contain a message similar to this example:
Shutdown request with time limit of 0 seconds received at Thu Feb 17 14:18:46 2011.
Shutdown will complete when all outstanding jobs are complete, or within 0 seconds, whichever happens earlier.
Shutdown time limit reached at Thu Feb 17 14:18:46 2011, exiting with jobs still in progress:
1 request is still active or queued, and will not be logged to the request log
1 job is currently executing, and will be killed.
0 jobs are queued, and will not be executed.