Skip to content

DOCS-1377 document missing isMaster fields #846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 115 additions & 43 deletions source/reference/command/isMaster.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,86 @@ isMaster

.. dbcommand:: isMaster

The :dbcommand:`isMaster` command provides a basic overview of the current
replication configuration. MongoDB :term:`drivers <driver>` and
The :dbcommand:`isMaster` command returns a document describing the
role of the :program:`mongod` instance it is run against. 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.

If sent to a :program:`mongod` instance which is not a member of a
replica set, a subset of information is returned.

MongoDB :term:`drivers <driver>` and
:term:`clients <client>` use this command to determine what kind of
member they're connected to and to discover additional members of a
:term:`replica set`. The :method:`db.isMaster()` method provides a
wrapper around this database command.
:term:`replica set`.

The :method:`db.isMaster()` method provides a wrapper around this
database command.

The :dbcommand:`isMaster` command returns a :term:`document` whose
contents vary depending on the role of the :program:`mongod` instance.

The command takes the following form:

.. code-block:: javascript

{ isMaster: 1 }

This command returns a :term:`document` containing the
following fields:

.. data:: isMaster.setname
**Common Fields**

The name of the current replica set, if applicable.
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 the current node is either a :term:`primary` in a
:term:`replica set`, a :term:`master` in a master-slave
configuration, or a standalone :program:`mongod`.
``true``, then this instance is a :term:`primary` in a
:term:`replica set`, or a :term:`master` in a master-slave
configuration, or a :program:`mongos` instance, or a standalone
:program:`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 :program:`mongod` process. If not provided, clients should
assume a max size of "``4 * 1024 * 1024``".

.. data:: isMaster.maxMessageSizeBytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this one was added in 2.4, and maxBsonObjectSize in 2.0
That should probably be included since the localTime field has a 'versionadded' statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I added a versionadded for maxMesageSizeBytes (2.3.2 is where I found it) but am not adding one for MaxBSONSize because it seems to predate 1.9.x


.. versionadded:: 2.3.2

The maximum permitted size of a :term:`BSON` wire protocol message.
The default value is ``48000000`` bytes.

.. data:: isMaster.localTime

.. versionadded:: 2.1.1

Returns the local server time in UTC. This value is an
:term:`ISOdate`.

**Shard Servers**

:program:`mongos` instances add the following field to the
:dbcommand:`isMaster` response document:

.. data:: isMaster.msg

Contains the value ``isdbgrid`` when :dbcommand:`isMaster`
is sent to a :program:`mongos` instance.

**Replica Sets**

The following :dbcommand:`isMaster` fields are added to the common
fields when the instance is a member of a replica set:

.. data:: isMaster.setName

The name of the current replica set.

.. data:: isMaster.secondary

Expand All @@ -41,52 +95,70 @@ isMaster

.. data:: isMaster.hosts

An array of strings in the format of "``[hostname]:[port]``"
listing all members of the :term:`replica set` that are not
":term:`hidden <hidden member>`".
An array of strings in the format of ``"[hostname]:[port]"``
listing all members of the :term:`replica set` that are neither
:term:`hidden <hidden member>`, :term:`passive <passive member>`,
nor :term:`arbiters <arbiter>`.

.. data:: isMaster.arbiter
Drivers use this array and the :data:`isMaster.passives` to determine
which members to read from.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not list arbiters either

An array of strings in the format of "``[hostname]:[port]``"
listing all members of the :term:`replica set` that are
:term:`arbiters <arbiter>`
.. data:: isMaster.passives

Only appears in the :dbcommand:`isMaster` response for replica
sets that have arbiter members.
An array of strings in the format of ``"[hostname]:[port]"``
listing all members of the :term:`replica set` which have a
:ref:`priority <replica-set-node-priority>` of ``0``.

.. data:: isMaster.arbiterOnly
This field only appears if there is at least one member with a
:ref:`priority <replica-set-node-priority>` of ``0``.

Drivers use this array and the :data:`isMaster.hosts` to determine
which members to read from.

A boolean value that, when ``true`` indicates that the current
instance is an :term:`arbiter`.
.. data:: isMaster.arbiters

:data:`~isMaster.arbiterOnly` only appears in the
:dbcommand:`isMaster` response from 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

The ``[hostname]:[port]`` for the current
:term:`replica set` :term:`primary`, if applicable.
A string in the format of ``"[hostname]:[port]"`` listing the
current :term:`primary` member of the replica set.

.. data:: isMaster.me
.. data:: isMaster.arbiterOnly

The ``[hostname]:[port]`` of the node responding to this
command.
A boolean value that indicates that the current instance is an
:term:`arbiter`.
The :data:`~isMaster.arbiterOnly` field will only be present, with
a value of ``true``, if the instance is an arbiter.

.. data:: isMaster.maxBsonObjectSize
.. data:: isMaster.passive

The maximum permitted size of a :term:`BSON` object in bytes for
this :program:`mongod` process. If not provided, clients should
assume a max size of "``4 * 1024 * 1024``".
A boolean value that indicates that the current instance is
:term:`hidden`.
The :data:`~isMaster.passive` field will only be present, with
a value of ``true``, if the instance is hidden.

.. data:: isMaster.localTime
.. data:: isMaster.hidden

.. versionadded:: 2.1.1
A boolean value that indicates that the current instance is
:term:`hidden`.
The :data:`~isMaster.hidden` field will only be present, with
a value of ``true``, if the instance is hidden.

.. data:: isMaster.tags

A document that lists any tags assigned to this member.
This field is only present if there are tags assigned to the member.

.. data:: isMaster.me

Returns the local server time in UTC. This value is a
:term:`ISOdate`. You can use the :js:func:`toString()`
JavaScript method to convert this value to a local date string,
as in the following example:
The ``[hostname]:[port]`` of the member responding to this command.

.. code-block:: javascript
.. seealso::

db.isMaster().localTime.toString();
:method:`db.isMaster()`
4 changes: 4 additions & 0 deletions source/reference/glossary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ Glossary
:dbcommand:`isMaster`, :method:`db.isMaster`, and
:data:`local.system.replset.members[n].hidden`.

passive member
A member of a :term:`replica set` that cannot become primary
because its :ref:`priority <replica-set-node-priority>` is ``0``.

delayed member
A member of a :term:`replica set` that cannot become primary and
applies operations at a specified delay. This delay is useful
Expand Down
15 changes: 9 additions & 6 deletions source/reference/method/db.isMaster.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ db.isMaster()

.. method:: db.isMaster()

Returns a status document with fields that includes the
``ismaster`` field that reports if the current node is the
:term:`primary` node, as well as a report of a subset of current
replica set configuration.
:returns: A document describing the role of the :program:`mongod`
instance. If the instance is a member of a replica set, then
the fields :data:`isMaster.ismaster` and :data:`isMaster.secondary`
can be used to determine if the instance is the :term:`primary` or
if it is a :term:`secondary` member.

This function provides a wrapper around the :term:`database command`
:dbcommand:`isMaster`
.. see::

:dbcommand:`isMaster` for the complete description of the output
of this command.