Skip to content

Commit 30980cc

Browse files
author
Bob Grabar
committed
DOCS-437 troubleshooting an oplog error
1 parent 861b3f4 commit 30980cc

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

source/administration/replica-sets.txt

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -698,36 +698,60 @@ the appropriate :term:`write concern`.
698698

699699
.. include:: /includes/seealso-elections.rst
700700

701-
Oplog Entry Error
702-
~~~~~~~~~~~~~~~~~
701+
Oplog Entry Timestamp Error
702+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
703703

704704
.. TODO link this topic to assertion 13290 once assertion guide exists.
705705

706-
If you receive the following errors:
706+
If you receive the following error:
707707

708708
.. code-block:: javascript
709709

710710
replSet error fatal couldn't query the local local.oplog.rs collection. Terminating mongod after 30 seconds.
711711
bad replSet oplog entry?
712712

713-
Then the errors might indicate that the ``ts`` field in the last oplog
714-
entry is of the wrong data type.
713+
Then the value for the ``ts`` field in the last oplog entry might be of
714+
the wrong data type. The correct data type is Timestamp.
715715

716-
You can check this with the following command:
716+
You can check the data type by running the following two queries. If the
717+
data type is correct, the queries return the same document; if
718+
incorrect, they return different documents.
719+
720+
First run a query to return the last document in the oplog, no matter
721+
its data type:
722+
723+
.. code-block:: javascript
724+
725+
db.oplog.rs.find().sort({$natural:-1}).limit(1)
726+
727+
Then run a query to return the last document in the oplog where the
728+
``ts`` value is a Timestamp. Use the :operator:`$type` operator to query
729+
for type ``17``, which is the Timestamp data type.
717730

718731
.. code-block:: javascript
719732

720-
db.oplog.rs.find({ts:{$type:17}}).({$natural:-1}).limit(1)
733+
db.oplog.rs.find({ts:{$type:17}}).sort({$natural:-1}).limit(1)
734+
735+
.. example::
736+
737+
As an example, if the first query returns this as the last oplog entry:
738+
739+
.. code-block:: javascript
740+
741+
{ "h" : NumberLong("8191276672478122996"), "ns" : "", "o" : { "msg" : "Reconfig set", "version" : 4 }, "op" : "n", "ts" : true }
721742

722-
If the ts field is of the wrong type, you receive the same error.
743+
And the second query returns this as the last entry where ``ts`` is a Timestamp:
723744

724-
To verify there are no other issues, run the following command:
745+
.. code-block:: javascript
725746

726-
db.oplog.rs.find().({$natural:-1}).limit(1)
747+
{ "ts" : Timestamp(1347982454000, 1), "h" : NumberLong("6188469075153256465"), "op" : "n", "ns" : "", "o" : { "msg" : "Reconfig set", "version" : 3 } }
727748

728-
If there are no other issues, this returns without error.
749+
Then the value for the ``ts`` field in the last oplog entry is of the
750+
wrong data type.
729751

730-
To fix the ``ts`` data type, run the following:
752+
To fix the ``ts`` data type, you can run the following update. Note,
753+
however, that this update scans the whole oplog and can take a lot of
754+
time to pull the oplog into memory:
731755

732756
.. code-block:: javascript
733757

0 commit comments

Comments
 (0)