0

We recently upgraded our mongo replica set from 2.4 to 2.6.12 and are having the strange behavior that the primary uses the indexes and the secondaries do not.

for instance this query:

query fitly_metrics_production.rank_ledger_entries query: { $query: { 
user_id: ObjectId('56dd084df093a136580be18a'), category: "chest" }, 
$orderby: { _id: -1 } } planSummary: IXSCAN { _id: 1 } ntoskip:0 
nscanned:1645536 nscannedObjects:1645536 keyUpdates:0 numYields:12866 
locks(micros) r:138352610 nreturned:1 reslen:316 481856ms

when run explain() on it on the same box we see

{
"cursor" : "BtreeCursor user_id_1_category_1",
"isMultiKey" : false,
"n" : 9,
"nscannedObjects" : 9,
"nscanned" : 9,
"nscannedObjectsAllPlans" : 30,
"nscannedAllPlans" : 30,
"scanAndOrder" : true,
"indexOnly" : false,
"nYields" : 0,
"nChunkSkips" : 0,
"millis" : 0,
"indexBounds" : {
    "user_id" : [
        [
            ObjectId("56dd084df093a136580be18a"),
            ObjectId("56dd084df093a136580be18a")
        ]
    ],
    "category" : [
        [
            "chest",
            "chest"
        ]
    ]
},
"server" : "ip-10-7-2-11:27017",
"filterSet" : false
}

and when run on the primary it does hit the index properly, we have two secondaries and this is occurring on both secondaries.

Any idea of what is going on? Thanks.

frausto
  • 51
  • 6
  • most probably you'll have to rebuild indexes on secondaries. check if your secondaries do have indexes. – Saleem Apr 20 '16 at 01:19
  • We rebuilt the indexes on both secondaries and the problem still occurs – frausto Apr 20 '16 at 19:09
  • interesting. can you post explain for primary and secondaries? It could be a bug. If you have luxury, upgrading to latest is highly recommended. – Saleem Apr 20 '16 at 19:15

0 Answers0