diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/cmdline.cpp | 4 | ||||
-rw-r--r-- | db/commands/mr.cpp | 3 | ||||
-rw-r--r-- | db/db.cpp | 16 | ||||
-rw-r--r-- | db/dbcommands.cpp | 1 | ||||
-rw-r--r-- | db/dur.cpp | 2 | ||||
-rw-r--r-- | db/dur_commitjob.h | 4 | ||||
-rw-r--r-- | db/ops/update.cpp | 28 | ||||
-rw-r--r-- | db/ops/update.h | 3 | ||||
-rw-r--r-- | db/pdfile.cpp | 5 | ||||
-rw-r--r-- | db/pdfile.h | 2 | ||||
-rw-r--r-- | db/repl/manager.cpp | 10 | ||||
-rw-r--r-- | db/repl/rs.cpp | 6 |
12 files changed, 49 insertions, 35 deletions
diff --git a/db/cmdline.cpp b/db/cmdline.cpp index fd759a7..346a9ae 100644 --- a/db/cmdline.cpp +++ b/db/cmdline.cpp @@ -239,7 +239,7 @@ namespace mongo { cmdLine.noUnixSocket = true; } - if (params.count("fork")) { + if (params.count("fork") && !params.count("shutdown")) { if ( ! params.count( "logpath" ) ) { cout << "--fork has to be used with --logpath" << endl; ::exit(-1); @@ -304,7 +304,7 @@ namespace mongo { } #endif - if (params.count("logpath")) { + if (params.count("logpath") && !params.count("shutdown")) { if ( logpath.size() == 0 ) logpath = params["logpath"].as<string>(); uassert( 10033 , "logpath has to be non-zero" , logpath.size() ); diff --git a/db/commands/mr.cpp b/db/commands/mr.cpp index b79e62b..30fa2a4 100644 --- a/db/commands/mr.cpp +++ b/db/commands/mr.cpp @@ -940,6 +940,7 @@ namespace mongo { log(1) << "mr ns: " << config.ns << endl; + uassert( 16149 , "cannot run map reduce without the js engine", globalScriptEngine ); bool shouldHaveData = false; long long num = 0; @@ -1206,7 +1207,7 @@ namespace mongo { BSONObj res = config.reducer->finalReduce( values , config.finalizer.get()); if (state.isOnDisk()) - state.insertToInc(res); + state.insert( config.tempLong , res ); else state.emit(res); values.clear(); @@ -989,22 +989,6 @@ int main(int argc, char* argv[]) { procPath = (str::stream() << "/proc/" << pid); if (!boost::filesystem::exists(procPath)) failed = true; - - string exePath = procPath + "/exe"; - if (boost::filesystem::exists(exePath)){ - char buf[256]; - int ret = readlink(exePath.c_str(), buf, sizeof(buf)-1); - buf[ret] = '\0'; // readlink doesn't terminate string - if (ret == -1) { - int e = errno; - cerr << "Error resolving " << exePath << ": " << errnoWithDescription(e); - failed = true; - } - else if (!endsWith(buf, "mongod")){ - cerr << "Process " << pid << " is running " << buf << " not mongod" << endl; - ::exit(-1); - } - } } catch (const std::exception& e){ cerr << "Error reading pid from lock file [" << name << "]: " << e.what() << endl; diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index fc6327c..fb6a902 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -1760,6 +1760,7 @@ namespace mongo { virtual bool slaveOk() const { return false; } virtual LockType locktype() const { return WRITE; } virtual bool requiresAuth() { return true; } + virtual bool logTheOp() { return true; } virtual bool run(const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool) { string coll = cmdObj[ "emptycapped" ].valuestrsafe(); uassert( 13428, "emptycapped must specify a collection", !coll.empty() ); @@ -83,7 +83,7 @@ namespace mongo { */ static void groupCommit(); - CommitJob commitJob; + CommitJob& commitJob = *(new CommitJob()); // don't destroy Stats stats; diff --git a/db/dur_commitjob.h b/db/dur_commitjob.h index a5f8515..ab62c2a 100644 --- a/db/dur_commitjob.h +++ b/db/dur_commitjob.h @@ -164,6 +164,8 @@ namespace mongo { CommitJob(); + ~CommitJob(){ assert(!"shouldn't destroy CommitJob!"); } + /** record/note an intent to write */ void note(void* p, int len); @@ -212,7 +214,7 @@ namespace mongo { unsigned _nSinceCommitIfNeededCall; }; - extern CommitJob commitJob; + extern CommitJob& commitJob; } } diff --git a/db/ops/update.cpp b/db/ops/update.cpp index 6a7aad4..4fb8750 100644 --- a/db/ops/update.cpp +++ b/db/ops/update.cpp @@ -642,6 +642,14 @@ namespace mongo { } + bool ModSetState::duplicateFieldName( const BSONElement &a, const BSONElement &b ) { + return + !a.eoo() && + !b.eoo() && + ( a.rawdata() != b.rawdata() ) && + ( a.fieldName() == string( b.fieldName() ) ); + } + template< class Builder > void ModSetState::createNewFromMods( const string& root , Builder& b , const BSONObj &obj ) { DEBUGUPDATE( "\t\t createNewFromMods root: " << root ); @@ -654,8 +662,18 @@ namespace mongo { ModStateHolder::iterator mend = _mods.lower_bound( buf.str() ); set<string> onedownseen; - + BSONElement prevE; while ( e.type() && m != mend ) { + + if ( duplicateFieldName( prevE, e ) ) { + // Just copy through an element with a duplicate field name. + b.append( e ); + prevE = e; + e = es.next(); + continue; + } + prevE = e; + string field = root + e.fieldName(); FieldCompareResult cmp = compareDottedFieldNames( m->second.m->fieldName , field ); @@ -684,11 +702,9 @@ namespace mongo { m++; } else { - // this is a very weird case - // have seen it in production, but can't reproduce - // this assert prevents an inf. loop - // but likely isn't the correct solution - assert(0); + massert( 16062 , "ModSet::createNewFromMods - " + "SERVER-4777 unhandled duplicate field" , 0 ); + } continue; } diff --git a/db/ops/update.h b/db/ops/update.h index de5805a..73e4437 100644 --- a/db/ops/update.h +++ b/db/ops/update.h @@ -623,6 +623,9 @@ namespace mongo { } + /** @return true iff the elements aren't eoo(), are distinct, and share a field name. */ + static bool duplicateFieldName( const BSONElement &a, const BSONElement &b ); + public: bool canApplyInPlace() const { diff --git a/db/pdfile.cpp b/db/pdfile.cpp index ac7731a..60914d9 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -434,6 +434,7 @@ namespace mongo { } Extent* MongoDataFile::createExtent(const char *ns, int approxSize, bool newCapped, int loops) { + assert( approxSize <= Extent::maxSize() ); { // make sizes align with VM page size int newSize = (approxSize + 0xfff) & 0xfffff000; @@ -491,6 +492,10 @@ namespace mongo { // overflowed high = max(approxSize, Extent::maxSize()); } + if ( high <= Extent::minSize() ) { + // the minimum extent size is 4097 + high = Extent::minSize() + 1; + } int n = 0; Extent *best = 0; int bestDiff = 0x7fffffff; diff --git a/db/pdfile.h b/db/pdfile.h index 64dba68..2652f54 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -313,7 +313,7 @@ namespace mongo { Extent* getPrevExtent() { return xprev.isNull() ? 0 : DataFileMgr::getExtent(xprev); } static int maxSize(); - static int minSize() { return 0x100; } + static int minSize() { return 0x1000; } /** * @param len lengt of record we need * @param lastRecord size of last extent which is a factor in next extent size diff --git a/db/repl/manager.cpp b/db/repl/manager.cpp index c91adc3..fb9b6cb 100644 --- a/db/repl/manager.cpp +++ b/db/repl/manager.cpp @@ -98,8 +98,14 @@ namespace mongo { const Member *primary = rs->box.getPrimary(); if (primary && highestPriority && - highestPriority->config().priority > primary->config().priority) { - log() << "stepping down " << primary->fullName() << endl; + highestPriority->config().priority > primary->config().priority && + // if we're stepping down to allow another member to become primary, we + // better have another member (otherOp), and it should be up-to-date + otherOp != 0 && highestPriority->hbinfo().opTime.getSecs() >= otherOp - 10) { + log() << "stepping down " << primary->fullName() << " (priority " << + primary->config().priority << "), " << highestPriority->fullName() << + " is priority " << highestPriority->config().priority << " and " << + (otherOp - highestPriority->hbinfo().opTime.getSecs()) << " seconds behind" << endl; if (primary->h().isSelf()) { // replSetStepDown tries to acquire the same lock diff --git a/db/repl/rs.cpp b/db/repl/rs.cpp index 23abc24..9181fe9 100644 --- a/db/repl/rs.cpp +++ b/db/repl/rs.cpp @@ -119,8 +119,6 @@ namespace mongo { return max; } - const bool closeOnRelinquish = true; - void ReplSetImpl::relinquish() { LOG(2) << "replSet attempting to relinquish" << endl; if( box.getState().primary() ) { @@ -129,9 +127,7 @@ namespace mongo { log() << "replSet relinquishing primary state" << rsLog; changeState(MemberState::RS_SECONDARY); - } - - if( closeOnRelinquish ) { + /* close sockets that were talking to us so they don't blithly send many writes that will fail with "not master" (of course client could check result code, but in case they are not) */ |