diff options
author | Dwight <dmerriman@gmail.com> | 2008-09-04 18:24:03 -0400 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2008-09-04 18:24:03 -0400 |
commit | 5f9d52a2f5fc4e85691ec32a4199c5dfd16b04d2 (patch) | |
tree | 13c657aff1dd8dce400bb7167d41b6314300caff | |
parent | 5deec924696d34505ba1bb75cebfab4a66ddec33 (diff) | |
download | mongo-5f9d52a2f5fc4e85691ec32a4199c5dfd16b04d2.tar.gz |
more work on pairing
-rw-r--r-- | db/db.cpp | 2 | ||||
-rw-r--r-- | db/pdfile.cpp | 7 | ||||
-rw-r--r-- | db/pdfile.h | 2 | ||||
-rw-r--r-- | db/repl.cpp | 25 | ||||
-rw-r--r-- | db/repl.h | 1 | ||||
-rw-r--r-- | grid/message.cpp | 2 |
6 files changed, 27 insertions, 12 deletions
diff --git a/db/db.cpp b/db/db.cpp index f65335ad41e..03f54fa2678 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -374,7 +374,7 @@ public: 115 replay, opLogging */ void listen(int port) { - const char *Version = "db version: 121"; + const char *Version = "db version: 122"; problem() << Version << endl; pdfileInit(); //testTheDb(); diff --git a/db/pdfile.cpp b/db/pdfile.cpp index 712924b8f6e..913ecc5060a 100644 --- a/db/pdfile.cpp +++ b/db/pdfile.cpp @@ -181,7 +181,7 @@ Extent* PhysicalDataFile::newExtent(const char *ns, int approxSize, int loops) { assert( loops < 10000 ); cout << "warning: loops=" << loops << " fileno:" << fileNo << ' ' << ns << '\n'; } - cout << "info: newExtent(): file " << fileNo << " full, adding a new file " << ns << endl; + log() << "newExtent: " << ns << " file " << fileNo << " full, adding a new file\n"; return client->addAFile()->newExtent(ns, approxSize, loops+1); } int offset = header->unused.getOfs(); @@ -209,9 +209,8 @@ Extent* PhysicalDataFile::newExtent(const char *ns, int approxSize, int loops) { DEBUGGING cout << "temp: newextent adddelrec " << ns << endl; details->addDeletedRec(emptyLoc.drec(), emptyLoc); - log() << "new extent size: 0x" << hex << ExtentSize << " loc: 0x" << hex << offset - << " emptyLoc:" << hex << emptyLoc.getOfs() << dec - << ' ' << ns << endl; + log() << "new extent " << ns << " size: 0x" << hex << ExtentSize << " loc: 0x" << hex << offset + << " emptyLoc:" << hex << emptyLoc.getOfs() << dec << endl; return e; } diff --git a/db/pdfile.h b/db/pdfile.h index c0e9b2d44c1..96ad7d160f3 100644 --- a/db/pdfile.h +++ b/db/pdfile.h @@ -384,7 +384,7 @@ inline void setClient(const char *ns) { client = it->second; return; } - problem() << "first request for database " << cl << endl; + log() << "first operation for database " << cl << endl; Client *c = new Client(cl); clients[cl] = c; client = c; diff --git a/db/repl.cpp b/db/repl.cpp index 6c88ba9a250..817524e180f 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -74,10 +74,12 @@ int test2() { ReplSource::ReplSource() { nClonedThisPass = 0; + paired = false; sourceName = "main"; } ReplSource::ReplSource(JSObj o) : nClonedThisPass(0) { + paired = false; only = o.getStringField("only"); hostName = o.getStringField("host"); sourceName = o.getStringField("source"); @@ -133,8 +135,8 @@ void ReplSource::save() { setClient("local.sources"); //cout << o.toString() << endl; //cout << pattern.toString() << endl; - int u = _updateObjects("local.sources", o, pattern, false, ss); - assert( u == 1 ); + int u = _updateObjects("local.sources", o, pattern, true/*upsert for pair feature*/, ss); + assert( u == 1 || u == 4 ); client = 0; } @@ -178,6 +180,7 @@ void ReplSource::loadAll(vector<ReplSource*>& v) { if( !gotPairWith && replSetPair ) { /* add the --pairwith server */ ReplSource *s = new ReplSource(); + s->paired = true; s->hostName = replSetPair->remote; v.push_back(s); } @@ -247,9 +250,21 @@ void ReplSource::sync_pullOpLog_applyOperation(JSObj& op) { if( client->justCreated || /* datafiles were missing. so we need everything, no matter what sources object says */ newDb ) /* if not in dbs, we've never synced this database before, so we need everything */ { - nClonedThisPass++; - resync(client->name); - client->justCreated = false; + if( paired && !client->justCreated ) { + /* the other half of our pair has some operations. yet we already had a db on our + disk even though the db in question is not listed in the source. this is normal + near the beginning of paired operation. + + todo: we should echo back an optime on the initial cloning, and then we know + we are safely in sync, and if we get here without that, we can then error out. + */ + log() << "TEMP: pair: assuming we have the historical image for: " << clientName << endl; + } + else { + nClonedThisPass++; + resync(client->name); + client->justCreated = false; + } } stringstream ss; diff --git a/db/repl.h b/db/repl.h index 9af8aec9d69..be9d14e2d1d 100644 --- a/db/repl.h +++ b/db/repl.h @@ -95,6 +95,7 @@ class ReplSource { ReplSource(); public: + bool paired; // --pair in use string hostName; // ip addr or hostname string sourceName; // a logical source name. string only; // only a certain db. note that in the sources collection, this may not be changed once you start replicating. diff --git a/grid/message.cpp b/grid/message.cpp index bccdfec8a52..4b40b964be3 100644 --- a/grid/message.cpp +++ b/grid/message.cpp @@ -112,7 +112,7 @@ bool MessagingPort::connect(SockAddr& _far) return false; } if( ::connect(sock, (sockaddr *) &farEnd.sa, farEnd.addressSize) ) { - log() << "connect(): failed errno:" << errno << ' ' << farEnd.getPort() << endl; +// log() << "connect(): failed errno:" << errno << ' ' << farEnd.getPort() << endl; closesocket(sock); sock = -1; return false; } |