0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

more work on pairing

This commit is contained in:
Dwight 2008-09-04 18:24:03 -04:00
parent 5deec92469
commit 5f9d52a2f5
6 changed files with 27 additions and 12 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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;
}