From 8ffaa3e2d9fbf731021cf3fe760d0a7cf42f8d76 Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 17 Mar 2009 13:48:40 -0400 Subject: [PATCH] Remove 'haveLogged' --- db/database.h | 8 -------- db/dbinfo.cpp | 12 ------------ db/dbinfo.h | 23 +---------------------- db/instance.cpp | 1 - db/repl.cpp | 9 +-------- dbtests/repltests.cpp | 2 -- 6 files changed, 2 insertions(+), 53 deletions(-) diff --git a/db/database.h b/db/database.h index cd21d7ca90f..76db293cad2 100644 --- a/db/database.h +++ b/db/database.h @@ -125,14 +125,6 @@ namespace mongo { int profile; // 0=off. string profileName; // "alleyinsider.system.profile" - bool haveLogged() { - return _haveLogged; - } - void setHaveLogged(); - - private: - // see dbinfo.h description. if true, we have logged to the replication log. - bool _haveLogged; }; extern Database *database; diff --git a/db/dbinfo.cpp b/db/dbinfo.cpp index 79ece1f6eca..bbae1428f76 100644 --- a/db/dbinfo.cpp +++ b/db/dbinfo.cpp @@ -22,18 +22,6 @@ namespace mongo { - void DBInfo::setHaveLogged() { - if ( haveLogged() ) - return; - - NamespaceDetails *d = nsdetails(ns.c_str()); - assert( d == 0 || d->nrecords == 0 ); - BSONObjBuilder b; - b.appendBool("haveLogged", true); - BSONObj o = b.done(); - theDataFileMgr.insert(ns.c_str(), (void *) o.objdata(), o.objsize()); - } - void DBInfo::dbDropped() { BSONObj empty; deleteObjects(ns.c_str(), empty, false); diff --git a/db/dbinfo.h b/db/dbinfo.h index 7c72ea84624..4c70a78f507 100644 --- a/db/dbinfo.h +++ b/db/dbinfo.h @@ -23,15 +23,7 @@ namespace mongo { /* this is an "accessor" class to data held in local.dbinfo. system.dbinfo contains: - - { haveLogged : true } - - haveLogged -- if true, we have already logged events to the oplog for this - database. missing implies false. - - other attributes will be added later. - - Note that class Database caches the DBInfo::haveLogged() value to keep things fast. + attributes will be added later. */ class DBInfo { string ns; @@ -53,24 +45,11 @@ namespace mongo { return c->current(); } - bool haveLogged() { - return getDbInfoObj().getBoolField("haveLogged"); - } - - void setHaveLogged(); void dbDropped(); }; - inline void Database::setHaveLogged() { - if ( _haveLogged ) return; - DBInfo i(name.c_str()); - i.setHaveLogged(); - _haveLogged = true; - } - inline void Database::finishInit() { DBInfo i(name.c_str()); - _haveLogged = i.haveLogged(); } } // namespace mongo diff --git a/db/instance.cpp b/db/instance.cpp index 7e2556c0243..d9329b5f11b 100644 --- a/db/instance.cpp +++ b/db/instance.cpp @@ -270,7 +270,6 @@ namespace mongo { } void closeClient( const char *cl, const char *path ) { - /* reset haveLogged in local.dbinfo */ if ( string("local") != cl ) { DBInfo i(cl); i.dbDropped(); diff --git a/db/repl.cpp b/db/repl.cpp index b256e41fb44..2a43be5b829 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -27,8 +27,7 @@ local.sources - indicates what sources we pull from as a "slave", and the last update of each local.oplog.$main - our op log as "master" - local.dbinfo. - as master, have we already logged events to the oplog for this database? - { haveLogged : true } + local.dbinfo. local.pair.startup - can contain a special value indicating for a pair that we have the master copy. used when replacing other half of the pair which has permanently failed. local.pair.sync - { initialsynccomplete: 1 } @@ -1095,8 +1094,6 @@ namespace mongo { return; Database *oldClient = database; - bool haveLogged = database && database->haveLogged(); - /* we jump through a bunch of hoops here to avoid copying the obj buffer twice -- instead we do a single copy to the destination position in the memory mapped file. */ @@ -1109,10 +1106,6 @@ namespace mongo { b.appendBool("b", *bb); if ( o2 ) b.append("o2", *o2); - if ( !haveLogged ) { - if ( database ) // null on dropDatabase()'s logging. - database->setHaveLogged(); - } BSONObj partial = b.done(); int posz = partial.objsize(); int len = posz + obj.objsize() + 1 + 2 /*o:*/; diff --git a/dbtests/repltests.cpp b/dbtests/repltests.cpp index 48c37584018..9f4db3d1ef2 100644 --- a/dbtests/repltests.cpp +++ b/dbtests/repltests.cpp @@ -161,12 +161,10 @@ namespace ReplTests { class LogBasic : public Base { public: void run() { - ASSERT( !database->haveLogged() ); ASSERT( oneOp().isEmpty() ); client()->insert( ns(), fromjson( "{\"a\":\"b\"}" ) ); - ASSERT( database->haveLogged() ); ASSERT( !oneOp().isEmpty() ); } };