Skip to content

DOCS-8478: Size and Count accuracy in WT after unexpected shutdown #2712

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 1 commit 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
6 changes: 4 additions & 2 deletions source/includes/fact-unexpected-shutdown-accuracy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ The amount of drift depends on the number of insert, update, or delete
operations performed between the last :ref:`checkpoint
<storage-wiredtiger-checkpoints>` and the unclean shutdown. Checkpoints
usually occur every 60 seconds. However, :program:`mongod` instances running
with non-default :option:`syncDelay` settings may have more or less frequent
with non-default :option:`--syncdelay` settings may have more or less frequent
checkpoints.

Run :dbcommand:`validate` on each collection on the :program:`mongod` to
to restore the correct statistics after an unclean shutdown.
to restore the correct statistics after an unclean shutdown. If multiple
:program:`mongod` instances experienced an unclean shutdown, perform the
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somewhat on the fence on this second sentence. Can remove if necessary

validation procedure on each :program:`mongod`.
17 changes: 11 additions & 6 deletions source/reference/command/count.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@ Behavior

.. include:: /includes/extracts/fact-count-on-sharded-clusters-cmd-count.rst

For MongoDB instances using the :doc:`WiredTiger </core/wiredtiger>`
storage engine, after an unclean shutdown, statistics on size and count
may off by up to 1000 documents as reported by :dbcommand:`collStats`,
:dbcommand:`dbStats`, :dbcommand:`count`. To restore the correct
statistics for the collection, run :dbcommand:`validate` on the
collection.
Accuracy after Unexpected Shutdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. |cmd| replace:: :dbcommand:`count`
.. |opt| replace:: count

.. include:: /includes/fact-unexpected-shutdown-accuracy.rst

.. note::
This loss of accuracy only applies to :dbcommand:`count`
operations that do *not* include a query document.

Examples
--------
Expand Down
13 changes: 7 additions & 6 deletions source/reference/command/dbStats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ The time required to run the command depends on the total size of the
database. Because the command must touch all data files, the command
may take several seconds to run.

For MongoDB instances using the :doc:`WiredTiger </core/wiredtiger>`
storage engine, after an unclean shutdown, statistics on size and count
may off by up to 1000 documents as reported by :dbcommand:`collStats`,
:dbcommand:`dbStats`, :dbcommand:`count`. To restore the correct
statistics for the collection, run :dbcommand:`validate` on the
collection.
Accuracy after Unexpected Shutdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. |cmd| replace:: :dbcommand:`dbStats`
.. |opt| replace:: count and size

.. include:: /includes/fact-unexpected-shutdown-accuracy.rst

.. _dbstats-output:

Expand Down
10 changes: 9 additions & 1 deletion source/reference/method/db.collection.stats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ by ``scale``.
.. note::

The scale factor rounds values to whole numbers.

Depending on the storage engine, the data returned may differ. For details on
the fields, see :ref:`output details <collStats-output>`.

Accuracy after Unexpected Shutdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. |cmd| replace:: :method:`db.collection.stats()`
.. |opt| replace:: count and size

.. include:: /includes/fact-unexpected-shutdown-accuracy.rst

Index Filter Behavior
~~~~~~~~~~~~~~~~~~~~~

Expand Down
13 changes: 7 additions & 6 deletions source/reference/method/db.stats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ Description
Behavior
--------

For MongoDB instances using the :doc:`WiredTiger </core/wiredtiger>`
storage engine, after an unclean shutdown, statistics on size and count
may off by up to 1000 documents as reported by :dbcommand:`collStats`,
:dbcommand:`dbStats`, :dbcommand:`count`. To restore the correct
statistics for the collection, run :dbcommand:`validate` on the
collection.
Accuracy after Unexpected Shutdown
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. |cmd| replace:: :method:`db.stats`
.. |opt| replace:: count and size

.. include:: /includes/fact-unexpected-shutdown-accuracy.rst

Example
-------
Expand Down