/
isMaster.txt
317 lines (206 loc) · 9.38 KB
/
isMaster.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
========
isMaster
========
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
----------
.. dbcommand:: isMaster
.. deprecated:: 3.6.21 Use :dbcommand:`hello` instead.
:dbcommand:`isMaster` returns a document that describes the role of
the :binary:`~bin.mongod` instance.
If the instance is a member of a
replica set, then :dbcommand:`isMaster` returns a subset of the
replica set configuration and status including whether or not the
instance is the :term:`primary` of the replica set.
When sent to a :binary:`~bin.mongod` instance that is not a member of a
replica set, :dbcommand:`isMaster` returns a subset of this
information.
MongoDB :term:`drivers <driver>` and :term:`clients <client>` use
:dbcommand:`isMaster` to determine the state of the replica set
members and to discover additional members of a :term:`replica
set`.
The :method:`db.isMaster()` method in the :binary:`~bin.mongo` shell
provides a wrapper around :dbcommand:`isMaster`.
The command takes the following form:
.. code-block:: javascript
{ isMaster: 1 }
Output
------
All Instances
~~~~~~~~~~~~~
The following :dbcommand:`isMaster` fields are common across all
roles:
.. data:: isMaster.ismaster
A boolean value that reports when this node is writable. If
``true``, then this instance is a :term:`primary` in a
:term:`replica set`, or a :term:`master` in a master-slave
configuration, or a :binary:`~bin.mongos` instance, or a standalone
:binary:`~bin.mongod`.
This field will be ``false`` if the instance is a
:term:`secondary` member of a replica set or if the member is an
:term:`arbiter` of a replica set.
.. data:: isMaster.maxBsonObjectSize
The maximum permitted size of a :term:`BSON` object in bytes for
this :binary:`~bin.mongod` process. If not provided, clients should
assume a max size of "``16 * 1024 * 1024``".
.. data:: isMaster.maxMessageSizeBytes
The maximum permitted size of a :term:`BSON` wire protocol message.
The default value is ``48000000`` bytes.
.. data:: isMaster.maxWriteBatchSize
The maximum number of write operations permitted in a write batch.
If a batch exceeds this
:limit:`limit<Write Command Batch Limit Size>`, the client
driver divides the batch into smaller groups each with counts less
than or equal to the value of this field.
The value of this limit is ``100,000`` writes.
.. versionchanged:: 3.6
The limit raises from ``1,000`` to ``100,000`` writes. This limit
also applies to legacy ``OP_INSERT`` messages.
.. data:: isMaster.localTime
Returns the local server time in UTC. This value is an
:term:`ISO date <ISODate>`.
.. data:: isMaster.logicalSessionTimeoutMinutes
.. versionadded:: 3.6
.. include:: /includes/fact-session-timeout.rst
Only available when ``featureCompatibilityVersion`` is ``"3.6"``.
See :ref:`3.6-compatibility-enabled`.
.. data:: isMaster.minWireVersion
.. versionadded:: 2.6
The earliest version of the wire protocol that this
:binary:`~bin.mongod` or :binary:`~bin.mongos` instance is capable of using
to communicate with clients.
Clients may use :data:`~isMaster.minWireVersion` to help negotiate
compatibility with MongoDB.
.. data:: isMaster.maxWireVersion
.. versionadded:: 2.6
The latest version of the wire protocol that this :binary:`~bin.mongod`
or :binary:`~bin.mongos` instance is capable of using to communicate
with clients.
Clients may use :data:`~isMaster.maxWireVersion` to help negotiate
compatibility with MongoDB.
.. data:: isMaster.readOnly
.. versionadded:: 3.4
A boolean value that, when ``true``, indicates that the
:binary:`~bin.mongod` or :binary:`~bin.mongos` is running in read-only mode.
.. data:: isMaster.compression
.. versionadded:: 3.4
An array listing the compression algorithms used or available for
use (i.e. common to both the client and the :binary:`~bin.mongod` or
:binary:`~bin.mongos` instance) to compress the communication
between the client and the :binary:`~bin.mongod` or
:binary:`~bin.mongos` instance.
The field is only available if compression is used. For example:
- If the :binary:`~bin.mongod` is enabled to use both the
``snappy,zlib`` compressors and a client has specified ``zlib``,
the :data:`~isMaster.compression` field would contain:
.. code-block:: javascript
"compression": [ "zlib" ]
- If the :binary:`~bin.mongod` is enabled to use both the
``snappy,zlib`` compressors and a client has specified ``zlib,snappy``,
the :data:`~isMaster.compression` field would contain:
.. code-block:: javascript
"compression": [ "zlib", "snappy" ]
- If the :binary:`~bin.mongod` is enabled to use the
``snappy`` compressor and a client has specified ``zlib,snappy``,
the :data:`~isMaster.compression` field would contain :
.. code-block:: javascript
"compression": [ "snappy" ]
- If the :binary:`~bin.mongod` is enabled to use the ``snappy``
compressor and a client has specified ``zlib`` or the client has
specified no compressor, the field is omitted.
That is, if the client does not specify compression or if the
client specifies a compressor not enabled for the connected
:binary:`~bin.mongod` or :binary:`~bin.mongos` instance, the field
does not return.
Sharded Instances
~~~~~~~~~~~~~~~~~
:binary:`~bin.mongos` instances add the following field to the
:dbcommand:`isMaster` response document:
.. data:: isMaster.msg
Contains the value ``isdbgrid`` when :dbcommand:`isMaster`
returns from a :binary:`~bin.mongos` instance.
Replica Sets
~~~~~~~~~~~~
:dbcommand:`isMaster` contains these fields when returned by a member
of a replica set:
.. data:: isMaster.setName
The name of the current :replica set.
.. data:: isMaster.setVersion
.. versionadded:: 2.6
The current replica set config version.
.. data:: isMaster.secondary
A boolean value that, when ``true``, indicates if the
:binary:`~bin.mongod` is a :term:`secondary` member of a :term:`replica
set`.
.. data:: isMaster.hosts
An array of strings in the format of ``"[hostname]:[port]"`` that
lists all members of the :term:`replica set` that are neither
:term:`hidden <hidden member>`, :term:`passive <passive member>`,
nor :term:`arbiters <arbiter>`.
Drivers use this array and the :data:`isMaster.passives` to determine
which members to read from.
.. data:: isMaster.passives
An array of strings in the format of ``"[hostname]:[port]"``
listing all members of the :term:`replica set` which have a
:rsconf:`members[n].priority` of ``0``.
This field only appears if there is at least one member with a
:rsconf:`members[n].priority` of ``0``.
Drivers use this array and the :data:`isMaster.hosts` to determine
which members to read from.
.. data:: isMaster.arbiters
An array of strings in the format of ``"[hostname]:[port]"``
listing all members of the :term:`replica set` that are
:term:`arbiters <arbiter>`.
This field only appears if there is at least one arbiter in the
replica set.
.. data:: isMaster.primary
A string in the format of ``"[hostname]:[port]"`` listing the
current :term:`primary` member of the replica set.
.. data:: isMaster.arbiterOnly
A boolean value that , when ``true``, indicates that the current
instance is an :term:`arbiter`. The :data:`~isMaster.arbiterOnly`
field is only present, if the instance is an arbiter.
.. data:: isMaster.passive
A boolean value that, when ``true``, indicates that the current
instance is :term:`passive <passive member>`. The
:data:`~isMaster.passive` field is only present for members with a
:rsconf:`members[n].priority` of ``0``.
.. data:: isMaster.hidden
A boolean value that, when ``true``, indicates that the current
instance is :term:`hidden <hidden member>`. The
:data:`~isMaster.hidden` field is only present for hidden members.
.. data:: isMaster.tags
.. include:: /includes/fact-tags-field.rst
.. seealso:: :rsconf:`members[n].tags`
.. data:: isMaster.me
The ``[hostname]:[port]`` of the member that returned
:dbcommand:`isMaster`.
.. data:: isMaster.electionId
.. versionadded:: 3.0
A unique identifier for each election. Included only in the output
of :dbcommand:`isMaster` for the :term:`primary`. Used by clients
to determine when elections occur.
.. data:: isMaster.lastWrite
.. versionadded:: 3.4
A document containing :term:`optime` and date information for the
database's most recent write operation.
.. data:: isMaster.lastWrite.opTime
An object giving the :term:`optime` of the last write operation.
.. data:: isMaster.lastWrite.lastWriteDate
A :bsontype:`date <data_date>` object containing the
time of the last write operation.
.. data:: isMaster.lastWrite.majorityOpTime
An object giving the :term:`optime` of the last write operation
readable by :readconcern:`majority <"majority">` reads.
.. data:: isMaster.lastWrite.majorityWriteDate
A :bsontype:`date <data_date>` object containing the
time of the last write operation readable by
:readconcern:`majority <"majority">` reads.
For details on the ``ok`` status field, the ``operationTime`` field,
and the ``$clusterTime`` field, see
:ref:`Command Response <command-response>`.