[SERVER-10464] Mongodump cannot query oplog.$main or oplog.rs when using --dbpath Created: 08/Aug/13  Updated: 11/Jul/16  Resolved: 16/May/14

Status: Closed
Project: Core Server
Component/s: Querying, Tools
Affects Version/s: 2.4.8, 2.6.1
Fix Version/s: 2.6.2, 2.7.1

Type: Bug Priority: Major - P3
Reporter: Scott Hernandez (Inactive) Assignee: Matt Dannenberg
Resolution: Done Votes: 0
Labels: mongodump
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to TOOLS-144 audit tools for correct use of oplogR... Closed
related to SERVER-14249 Add tests for querying oplog via mong... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Participants:

 Description   
Issue Status as of May 14, 2014

ISSUE SUMMARY
The mongodump tool fails to dump the local.oplog.rs and local.oplog.$main collections when the --dbpath argument is specified and quits with an error.

USER IMPACT
Users cannot dump an oplog directly from the files but need to start a mongod instead.

WORKAROUNDS
Affected users can create the dump from a running mongod instance and avoid the --dbpath option as a workaround. Another workaround is to pass in a query with a ts field as the --query argument.

AFFECTED VERSIONS
Version 2.6.1 was affected by this bug.

FIX VERSION
The fix is included in the 2.6.2 production release.

RESOLUTION DETAILS
The oplogReplay query option is only set if the query contains a ts field.

Original description

When issuing a query for the oplog (oplog.$main) an error is returned if the ts field is not supplied.

mongodump --dbpath /data/db/sconsTests -d local -c 'oplog.$main' -out /tmp/master
Thu Aug  8 09:07:40.653 [tools] Assertion: 13044:no ts field in query
0x1004482ab 0x10042332e 0x100226b5d 0x100226bca 0x1002278c7 0x1002307ff 0x100233c32 0x1001dfe5f 0x1001d7fc4 0x1001d81cd 0x10005053a 0x100029c70 0x1001d7b41 0x100008125 0x100008b2a 0x10000a740 0x1000046be 0x10041f69f 0x1000016ce 0x100001664 
 0   mongodump                           0x00000001004482ab _ZN5mongo15printStackTraceERSo + 43
 1   mongodump                           0x000000010042332e _ZN5mongo11msgassertedEiPKc + 174
 2   mongodump                           0x0000000100226b5d _ZN5mongo18FindingStartCursor4initEv + 1625
 3   mongodump                           0x0000000100226bca _ZN5mongo18FindingStartCursor4makeERKNS_9QueryPlanE + 100
 4   mongodump                           0x00000001002278c7 _ZN5mongo18FindingStartCursor9getCursorEPKcRKNS_7BSONObjES5_ + 821
 5   mongodump                           0x00000001002307ff _ZN5mongo23queryWithQueryOptimizerEiRKSsRKNS_7BSONObjERNS_5CurOpES4_S4_RKN5boost10shared_ptrINS_11ParsedQueryEEES4_RKNS_12ChunkVersionERNS7_10scoped_ptrINS_25PageFaultRetryableSectionEEERNSG_INS_19NoPageFaultsAllowedEEERNS_7MessageE + 207
 6   mongodump                           0x0000000100233c32 _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 5346
 7   mongodump                           0x00000001001dfe5f _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1519
 8   mongodump                           0x00000001001d7fc4 _ZN5mongo14DBDirectClient4callERNS_7MessageES2_bPSs + 112
 9   mongodump                           0x00000001001d81cd _ZThn72_N5mongo14DBDirectClient4callERNS_7MessageES2_bPSs + 13
 10  mongodump                           0x000000010005053a _ZN5mongo14DBClientCursor4initEv + 304
 11  mongodump                           0x0000000100029c70 _ZN5mongo12DBClientBase5queryERKSsNS_5QueryEiiPKNS_7BSONObjEii + 180
 12  mongodump                           0x00000001001d7b41 _ZN5mongo14DBDirectClient5queryERKSsNS_5QueryEiiPKNS_7BSONObjEii + 79
 13  mongodump                           0x0000000100008125 _ZN4Dump12doCollectionESsP7__sFILEPN5mongo13ProgressMeterE + 401
 14  mongodump                           0x0000000100008b2a _ZN4Dump19writeCollectionFileESsN5boost11filesystem34pathE + 706
 15  mongodump                           0x000000010000a740 _ZN4Dump2goESsN5boost11filesystem34pathE + 4286
 16  mongodump                           0x00000001000046be _ZN4Dump3runEv + 5612
 17  mongodump                           0x000000010041f69f _ZN5mongo4Tool4mainEiPPc + 4933
 18  mongodump                           0x00000001000016ce main + 62
 19  mongodump                           0x0000000100001664 start + 52
Thu Aug  8 09:07:40.658 [tools] assertion 13044 no ts field in query ns:local.oplog.$main query:{}
Thu Aug  8 09:07:40.658 [tools] 		 1 objects

Workaround:

mongodump --dbpath /data/db/sconsTests -d local -c 'oplog.$main' -q '{ts:{$exists:true}}' -out /tmp/master



 Comments   
Comment by Githook User [ 16/May/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-10464 allow mongodump to dump oplog without a query containing a ts field
(cherry picked from commit 50045df21469d45216c5fb8899d68818fcc7f38a)
Branch: v2.6
https://github.com/mongodb/mongo/commit/195a67eec3cf8a337b5f524d138206e83bf564d4

Comment by Githook User [ 16/May/14 ]

Author:

{u'username': u'dannenberg', u'name': u'matt dannenberg', u'email': u'matt.dannenberg@10gen.com'}

Message: SERVER-10464 allow mongodump to dump oplog without a query containing a ts field
Branch: master
https://github.com/mongodb/mongo/commit/50045df21469d45216c5fb8899d68818fcc7f38a

Comment by Asya Kamsky [ 07/May/14 ]

Confirmed - worked correctly with 2.6.0 and 2.5.5.

Comment by Eric Milkie [ 07/May/14 ]

This was working in early 2.6 but regressed in 2.6.1 as part of the cleanup for OplogReplay in the query code.

Comment by Asya Kamsky [ 07/May/14 ]

Just realized that original and current manifestation applies to oplog.rs

Here is 2.4 error:

2.4.8/bin/mongodump -d local -c oplog.rs --dbpath /data/rs3
Wed May  7 14:46:16.025 [tools] DATABASE: local	 to 	dump/local
Wed May  7 14:46:16.026 [tools] 	local.oplog.rs to dump/local/oplog.rs.bson
Wed May  7 14:46:16.027 [tools] Assertion: 13044:no ts field in query
0x10044cb4b 0x100427ace 0x1002297dd 0x10022984a 0x10022a547 0x10023356f 0x1002369a2 0x1001e2a6f 0x1001dabd4 0x1001daddd 0x10005268a 0x100029860 0x1001da751 0x100007d15 0x10000871a 0x10000a330 0x1000042ae 0x100423e3f 0x1000012ae 0x100001244
 0   mongodump                           0x000000010044cb4b _ZN5mongo15printStackTraceERSo + 43
 1   mongodump                           0x0000000100427ace _ZN5mongo11msgassertedEiPKc + 174
 2   mongodump                           0x00000001002297dd _ZN5mongo18FindingStartCursor4initEv + 1625
 3   mongodump                           0x000000010022984a _ZN5mongo18FindingStartCursor4makeERKNS_9QueryPlanE + 100
 4   mongodump                           0x000000010022a547 _ZN5mongo18FindingStartCursor9getCursorEPKcRKNS_7BSONObjES5_ + 821
 5   mongodump                           0x000000010023356f _ZN5mongo23queryWithQueryOptimizerEiRKSsRKNS_7BSONObjERNS_5CurOpES4_S4_RKN5boost10shared_ptrINS_11ParsedQueryEEES4_RKNS_12ChunkVersionERNS7_10scoped_ptrINS_25PageFaultRetryableSectionEEERNSG_INS_19NoPageFaultsAllowedEEERNS_7MessageE + 207
 6   mongodump                           0x00000001002369a2 _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 5346
 7   mongodump                           0x00000001001e2a6f _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1519
 8   mongodump                           0x00000001001dabd4 _ZN5mongo14DBDirectClient4callERNS_7MessageES2_bPSs + 112
 9   mongodump                           0x00000001001daddd _ZThn72_N5mongo14DBDirectClient4callERNS_7MessageES2_bPSs + 13
 10  mongodump                           0x000000010005268a _ZN5mongo14DBClientCursor4initEv + 304
 11  mongodump                           0x0000000100029860 _ZN5mongo12DBClientBase5queryERKSsNS_5QueryEiiPKNS_7BSONObjEii + 180
 12  mongodump                           0x00000001001da751 _ZN5mongo14DBDirectClient5queryERKSsNS_5QueryEiiPKNS_7BSONObjEii + 79
 13  mongodump                           0x0000000100007d15 _ZN4Dump12doCollectionESsP7__sFILEPN5mongo13ProgressMeterE + 401
 14  mongodump                           0x000000010000871a _ZN4Dump19writeCollectionFileESsN5boost11filesystem34pathE + 706
 15  mongodump                           0x000000010000a330 _ZN4Dump2goESsN5boost11filesystem34pathE + 4286
 16  mongodump                           0x00000001000042ae _ZN4Dump3runEv + 5612
 17  mongodump                           0x0000000100423e3f _ZN5mongo4Tool4mainEiPPc + 4933
 18  mongodump                           0x00000001000012ae main + 62
 19  mongodump                           0x0000000100001244 start + 52
Wed May  7 14:46:16.054 [tools] assertion 13044 no ts field in query ns:local.oplog.rs query:{}
Wed May  7 14:46:16.054 [tools] 		 1 objects
Wed May  7 14:46:16.054 [tools] 	Metadata for local.oplog.rs to dump/local/oplog.rs.metadata.json
Wed May  7 14:46:16.054 dbexit:
Wed May  7 14:46:16.054 [tools] shutdown: going to close listening sockets...
Wed May  7 14:46:16.054 [tools] shutdown: going to flush diaglog...

Comment by Asya Kamsky [ 07/May/14 ]

Nope, still there but now it's a different assert.
v2.6.1

$ mongodump -d local -c oplog.rs --dbpath /data/rs3
2014-05-07T14:45:05.742-0700 DATABASE: local	 to 	dump/local
2014-05-07T14:45:05.746-0700 	local.oplog.rs to dump/local/oplog.rs.bson
2014-05-07T14:45:05.758-0700 [tools] assertion 17007 Unable to execute query: OplogReplay query does not contain top-level $gt or $gte over the 'ts' field. ns:local.oplog.rs query:{}
2014-05-07T14:45:05.758-0700 		 1 documents
2014-05-07T14:45:05.758-0700 	Metadata for local.oplog.rs to dump/local/oplog.rs.metadata.json
2014-05-07T14:45:05.759-0700 [tools] dbexit:
2014-05-07T14:45:05.760-0700 [tools] shutdown: going to close listening sockets...
2014-05-07T14:45:05.760-0700 [tools] shutdown: going to flush diaglog...
2014-05-07T14:45:05.760-0700 [tools] shutdown: going to close sockets...
2014-05-07T14:45:05.760-0700 [tools] shutdown: waiting for fs preallocator...
2014-05-07T14:45:05.760-0700 [tools] shutdown: closing all files...
2014-05-07T14:45:05.761-0700 [tools] closeAllFiles() finished
2014-05-07T14:45:05.761-0700 [tools] shutdown: removing fs lock...
2014-05-07T14:45:05.764-0700 [tools] dbexit: really exiting now

Comment by Scott Hernandez (Inactive) [ 06/Mar/14 ]

This has gone away and now works. The last run didn't print anything because there was no oplog to dump, unfortunately.

Comment by Scott Hernandez (Inactive) [ 05/Mar/14 ]

No loger errors, but does not work either (workaround neither):

mongodump --dbpath /data/db/sconsTests -d local -c 'oplog.$main' -out /tmp/
Wed Mar  5 17:06:26.551 [tools] DATABASE: local	 to 	/tmp/local
Wed Mar  5 17:06:26.555 dbexit: 
Wed Mar  5 17:06:26.556 [tools] shutdown: going to close listening sockets...
Wed Mar  5 17:06:26.556 [tools] shutdown: going to flush diaglog...
Wed Mar  5 17:06:26.556 [tools] shutdown: going to close sockets...
Wed Mar  5 17:06:26.556 [tools] shutdown: waiting for fs preallocator...
Wed Mar  5 17:06:26.556 [tools] shutdown: closing all files...
Wed Mar  5 17:06:26.556 [tools] closeAllFiles() finished
Wed Mar  5 17:06:26.556 [tools] shutdown: removing fs lock...
Wed Mar  5 17:06:26.556 dbexit: really exiting now

Comment by Eric Milkie [ 05/Mar/14 ]

This may be fixed in 2.6; can you check?

Generated at Thu Feb 08 03:23:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.