@@ -15,25 +15,18 @@ Description
15
15
16
16
.. dbcommand:: replSetStepDown
17
17
18
- Forces the :term:`primary` of the replica set to become a
19
- :term:`secondary`, triggering an :ref:`election for primary
20
- <replica-set-election-internals>`. The command steps down the
21
- primary for a specified number of seconds; during this period, the
22
- stepdown member is ineligible from becoming primary.
23
-
24
- By default, the command only steps down the primary if an
25
- :data:`electable <~replSetGetConfig.members[n].priority>`
26
- secondary is up-to-date with the primary, waiting up to 10 seconds
27
- for a secondary to catch up.
28
-
29
- The command is only valid against the primary and will error if run
30
- on a non-primary member. :dbcommand:`replSetStepDown` can
31
- only run in the ``admin`` database and has the following prototype
32
- form:
18
+ .. |command-method| replace:: command
19
+ .. |stepdown-secs| replace:: ``replSetStepDown: <seconds>``
20
+ .. |behavior-ref| replace:: :ref:`replSetStepDown-behavior`
21
+
22
+ .. include:: /includes/stepdown-intro.rst
23
+
24
+ The :dbcommand:`replSetStepDown` can only run on the ``admin`` database
25
+ and has the following prototype form:
33
26
34
27
.. code-block:: javascript
35
28
36
- db.runCommand ( {
29
+ db.adminCommand ( {
37
30
replSetStepDown: <seconds>,
38
31
secondaryCatchUpPeriodSecs: <seconds>,
39
32
force: <true|false>
@@ -43,39 +36,18 @@ Description
43
36
44
37
.. include:: /includes/apiargs/command-replSetStepDown-field.rst
45
38
39
+ .. _replSetStepDown-behavior:
40
+
46
41
Behavior
47
42
--------
48
43
49
- .. versionadded:: 3.0
50
-
51
- Before stepping down, :dbcommand:`replSetStepDown` will attempt to
52
- terminate long running user operations that would block the primary
53
- from stepping down, such as an index build, a write operation or a
54
- map-reduce job.
55
-
56
- To avoid rollbacks, :dbcommand:`replSetStepDown`, by default, only
57
- steps down the primary if an electable secondary is completely caught up
58
- with the primary. The command will wait up to the
59
- ``secondaryCatchUpPeriodSecs`` for a secondary to catch up.
44
+ .. |force-option| replace:: You can override this behavior and issue with command with the ``force: true`` option to immediately step down the primary.
60
45
61
- If no electable secondary meets this criterion by the waiting period,
62
- the primary does not step down and the command errors. However, you can
63
- override this behavior by including the ``force: true`` option.
46
+ .. |command-method-name| replace:: :dbcommand:`replSetStepDown`
64
47
65
- Upon successful stepdown, :dbcommand:`replSetStepDown` forces all
66
- clients currently connected to the database to disconnect. This helps
67
- ensure that the clients maintain an accurate view of the replica set.
48
+ .. include:: /includes/stepdown-behavior.rst
68
49
69
- Because the disconnect includes the connection used to run the command,
70
- you cannot retrieve the return status of the command if the command
71
- completes successfully; i.e. you can only retrieve the return status of
72
- the command if it errors. When running the command in a script, the
73
- script should account for this behavior.
74
-
75
- .. note::
76
-
77
- :dbcommand:`replSetStepDown` blocks all writes to the primary while
78
- it runs.
50
+ .. include:: /includes/fact-stepdown-write-fail.rst
79
51
80
52
Examples
81
53
--------
@@ -86,14 +58,13 @@ Step Down with Default Options
86
58
The following example, run on the current primary, attempts to step
87
59
down the member for ``120`` seconds.
88
60
89
- The operation will wait up to the default ``10`` seconds for a
61
+ The operation waits up to the default ``10`` seconds for a
90
62
secondary to catch up. If no suitable secondary exists, the primary
91
63
does not step down and the command errors.
92
64
93
- .. note::
94
-
95
- The command blocks all writes to the primary while it runs.
65
+ .. include:: /includes/fact-stepdown-write-fail.rst
96
66
67
+ .. class:: copyable-code
97
68
.. code-block:: javascript
98
69
99
70
db.adminCommand( { replSetStepDown: 120 } )
@@ -106,10 +77,9 @@ down the member for ``120`` seconds, waiting up to ``15`` seconds for
106
77
an electable secondary to catch up. If no suitable secondary exists,
107
78
the primary does not step down and the command errors.
108
79
109
- .. note::
110
-
111
- The command blocks all writes to the primary while it runs.
80
+ .. include:: /includes/fact-stepdown-write-fail.rst
112
81
82
+ .. class:: copyable-code
113
83
.. code-block:: javascript
114
84
115
85
db.adminCommand( { replSetStepDown: 120, secondaryCatchUpPeriodSecs: 15 } )
@@ -122,10 +92,9 @@ down the member for ``120`` seconds, waiting up to ``15`` seconds for
122
92
an electable secondary to catch up. Because of the ``force: true``
123
93
option, the primary steps down even if no suitable secondary exists.
124
94
125
- .. note::
126
-
127
- The command blocks all writes to the primary while it runs.
95
+ .. include:: /includes/fact-stepdown-write-fail.rst
128
96
97
+ .. class:: copyable-code
129
98
.. code-block:: javascript
130
99
131
100
db.adminCommand( { replSetStepDown: 120, secondaryCatchUpPeriodSecs: 15, force: true } )
0 commit comments