Permalink
Browse files

Replication should not create _id index for capped collections SERVER…

…-4626
  • Loading branch information...
1 parent 8c259b9 commit 8849484b70ed0bbaf820e6fc49168fc399129bbc @kchodorow kchodorow committed Feb 15, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 db/oplog.cpp
View
@@ -687,6 +687,7 @@ namespace mongo {
o = fields[0].embeddedObject();
const char *ns = fields[1].valuestrsafe();
+ NamespaceDetails *nsd = nsdetails(ns);
// operation type -- see logOp() comments for types
const char *opType = fields[2].valuestrsafe();
@@ -714,7 +715,7 @@ namespace mongo {
}
else {
/* erh 10/16/2009 - this is probably not relevant any more since its auto-created, but not worth removing */
- RARELY ensureHaveIdIndex(ns); // otherwise updates will be slow
+ RARELY if (nsd && !nsd->capped) { ensureHaveIdIndex(ns); } // otherwise updates will be slow
/* todo : it may be better to do an insert here, and then catch the dup key exception and do update
then. very few upserts will not be inserts...
@@ -731,9 +732,9 @@ namespace mongo {
// - if not, updates would be slow
// - but if were by id would be slow on primary too so maybe ok
// - if on primary was by another key and there are other indexes, this could be very bad w/out an index
- // - if do create, odd to have on secondary but not primary. also can cause secondary to block for
- // quite a while on creation.
- RARELY ensureHaveIdIndex(ns); // otherwise updates will be super slow
+ // - if do create, odd to have on secondary but not primary. also can cause secondary to block for
+ // quite a while on creation.
+ RARELY if (nsd && !nsd->capped) { ensureHaveIdIndex(ns); } // otherwise updates will be super slow
OpDebug debug;
BSONObj updateCriteria = op.getObjectField("o2");
bool upsert = fields[3].booleanSafe();
@@ -751,7 +752,6 @@ namespace mongo {
// { _id:..., { x : {$size:...} }
// thus this is not ideal.
else {
- NamespaceDetails *nsd = nsdetails(ns);
if (nsd == NULL ||
(nsd->findIdIndex() >= 0 && Helpers::findById(nsd, updateCriteria).isNull()) ||

0 comments on commit 8849484

Please sign in to comment.