@@ -698,36 +698,60 @@ the appropriate :term:`write concern`.
698
698
699
699
.. include:: /includes/seealso-elections.rst
700
700
701
- Oplog Entry Error
702
- ~~~~~~~~~~~~~~~~~
701
+ Oplog Entry Timestamp Error
702
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
703
703
704
704
.. TODO link this topic to assertion 13290 once assertion guide exists.
705
705
706
- If you receive the following errors :
706
+ If you receive the following error :
707
707
708
708
.. code-block:: javascript
709
709
710
710
replSet error fatal couldn't query the local local.oplog.rs collection. Terminating mongod after 30 seconds.
711
711
bad replSet oplog entry?
712
712
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 .
715
715
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.
717
730
718
731
.. code-block:: javascript
719
732
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 }
721
742
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:
723
744
724
- To verify there are no other issues, run the following command:
745
+ .. code-block:: javascript
725
746
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 } }
727
748
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.
729
751
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:
731
755
732
756
.. code-block:: javascript
733
757
0 commit comments