summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/repl.cpp25
-rw-r--r--jstests/repl/repl7.js40
-rw-r--r--mongo.xcodeproj/project.pbxproj2
3 files changed, 65 insertions, 2 deletions
diff --git a/db/repl.cpp b/db/repl.cpp
index 35f70b3def2..bf0ada40240 100644
--- a/db/repl.cpp
+++ b/db/repl.cpp
@@ -436,6 +436,17 @@ namespace mongo {
//syncedTo.asDate() = e.date();
}
+ BSONObj dbsObj = o.getObjectField("dbsNextPass");
+ if ( !dbsObj.isEmpty() ) {
+ BSONObjIterator i(dbsObj);
+ while ( 1 ) {
+ BSONElement e = i.next();
+ if ( e.eoo() )
+ break;
+ addDbNextPass.insert( e.fieldName() );
+ }
+ }
+
repopulateDbsList( o );
}
@@ -457,6 +468,15 @@ namespace mongo {
}
if ( n )
b.append("dbs", dbs_builder.done());
+
+ BSONObjBuilder dbsNextPassBuilder;
+ n = 0;
+ for ( set<string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++ ) {
+ n++;
+ dbsNextPassBuilder.appendBool(i->c_str(), 1);
+ }
+ if ( n )
+ b.append("dbsNextPass", dbsNextPassBuilder.done());
return b.obj();
}
@@ -833,11 +853,12 @@ namespace mongo {
}
nClonedThisPass++;
resync(database->name);
- save(); // persist dbs
+ addDbNextPass.erase(clientName);
+ save(); // persist dbs, next pass dbs
} else {
applyOperation( op );
+ addDbNextPass.erase( clientName );
}
- addDbNextPass.erase(clientName);
database = 0;
}
diff --git a/jstests/repl/repl7.js b/jstests/repl/repl7.js
new file mode 100644
index 00000000000..6d253f6900e
--- /dev/null
+++ b/jstests/repl/repl7.js
@@ -0,0 +1,40 @@
+// Test persistence of list of dbs to add.
+
+var baseName = "jstests_repl7test";
+
+doTest = function( signal ) {
+
+ // spec small oplog for fast startup on 64bit machines
+ m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
+
+ for( n = "a"; n != "aaaaa"; n += "a" ) {
+ m.getDB( n ).a.save( {x:1} );
+ }
+
+ s = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+
+ assert.soon( function() {
+ return -1 != s.getDBNames().indexOf( "aa" );
+ } );
+
+ stopMongod( 27019, signal );
+ s = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:27018" );
+
+ assert.soon( function() {
+ for( n = "a"; n != "aaaaa"; n += "a" ) {
+ if ( -1 == s.getDBNames().indexOf( n ) )
+ return false;
+ }
+ return true;
+ } );
+
+ for( n = "a"; n != "aaaaa"; n += "a" ) {
+ assert.eq( 1, m.getDB( n ).a.find().count() );
+ }
+
+ stopMongod( 27019 );
+ stopMongod( 27018 );
+}
+
+doTest( 15 ); // SIGTERM
+doTest( 9 ); // SIGKILL
diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj
index d9117af6249..b4ede40c875 100644
--- a/mongo.xcodeproj/project.pbxproj
+++ b/mongo.xcodeproj/project.pbxproj
@@ -20,6 +20,7 @@
9302D99F0F30AB8C00DFA4EF /* ShellUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShellUtils.cpp; sourceTree = "<group>"; };
9302D9A00F30AB8C00DFA4EF /* ShellUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShellUtils.h; sourceTree = "<group>"; };
9302D9A20F30AB8C00DFA4EF /* utils.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = utils.js; sourceTree = "<group>"; };
+ 931183420F8277FD00A6DC44 /* repl7.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl7.js; sourceTree = "<group>"; };
931A027A0F58AA4400147C0E /* jsobjmanipulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jsobjmanipulator.h; sourceTree = "<group>"; };
93278F570F72D32900844664 /* gridfs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gridfs.cpp; sourceTree = "<group>"; };
93278F580F72D32900844664 /* gridfs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gridfs.h; sourceTree = "<group>"; };
@@ -615,6 +616,7 @@
93A8D2040F37544800C92B85 /* repl */ = {
isa = PBXGroup;
children = (
+ 931183420F8277FD00A6DC44 /* repl7.js */,
93D9469F0F7ABB0600C3C768 /* repl6.js */,
93D941BF0F77D64F00C3C768 /* replacePeer1.js */,
93D941C00F77D64F00C3C768 /* replacePeer2.js */,