summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/cloner.cpp4
-rw-r--r--db/pdfile.cpp2
-rw-r--r--jstests/disk/repair.js2
-rw-r--r--jstests/repair.js2
-rw-r--r--jstests/repl/repair.js14
-rw-r--r--mongo.xcodeproj/project.pbxproj2
-rw-r--r--shell/utils.js66
7 files changed, 57 insertions, 35 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp
index 6dd879b5f44..8dd06bd9c4e 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -234,7 +234,9 @@ namespace mongo {
continue;
}
}
- if( strchr(from_name, '$') ) {
+ if( strcmp( from_name, "local.oplog.$main" ) == 0 ) {
+ // nothing - want to clone this one
+ } else if( strchr(from_name, '$') ) {
// don't clone index namespaces -- we take care of those separately below.
log(2) << "\t\t not cloning because has $ " << endl;
continue;
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index ba5e6139179..377162670b1 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -1349,7 +1349,7 @@ namespace mongo {
*/
DiskLoc DataFileMgr::insert(const char *ns, const void *obuf, int len, bool god, const BSONElement &writeId, bool mayAddIndex) {
bool wouldAddIndex = false;
- massert( 10093 , "cannot insert into reserved $ collection", god || strchr(ns, '$') == 0 );
+ massert( 10093 , "cannot insert into reserved $ collection", god || strchr(ns, '$') == 0 || strcmp( ns, "local.oplog.$main" ) == 0 );
uassert( 10094 , "invalid ns", strchr( ns , '.' ) > 0 );
const char *sys = strstr(ns, "system.");
if ( sys ) {
diff --git a/jstests/disk/repair.js b/jstests/disk/repair.js
index 6c8d81b3f9e..4bc57b23f2d 100644
--- a/jstests/disk/repair.js
+++ b/jstests/disk/repair.js
@@ -10,7 +10,7 @@ resetDbpath( repairpath );
m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbpath, "--repairpath", repairpath, "--nohttpinterface", "--bind_ip", "127.0.0.1" );
db = m.getDB( baseName );
db[ baseName ].save( {} );
-db.runCommand( {repairDatabase:1, backupOriginalFiles:true} );
+assert.commandWorked( db.runCommand( {repairDatabase:1, backupOriginalFiles:true} ) );
files = listFiles( dbpath );
for( f in files ) {
diff --git a/jstests/repair.js b/jstests/repair.js
index 5548c2b7d45..338fe52b958 100644
--- a/jstests/repair.js
+++ b/jstests/repair.js
@@ -1,6 +1,6 @@
t = db.jstests_repair;
t.drop();
t.save( { i:1 } );
-db.repairDatabase();
+assert.commandWorked( db.repairDatabase() );
v = t.validate();
assert( v.valid , "not valid! " + tojson( v ) );
diff --git a/jstests/repl/repair.js b/jstests/repl/repair.js
new file mode 100644
index 00000000000..7cc77dee88d
--- /dev/null
+++ b/jstests/repl/repair.js
@@ -0,0 +1,14 @@
+// Test repair on master
+
+var baseName = "jstests_repl_repair";
+
+rt = new ReplTest( baseName );
+
+m = rt.start( true );
+
+m.getDB( baseName )[ baseName ].save( {} );
+var c = m.getDB( 'local' ).oplog.$main.count();
+assert.automsg( "c > 0" );
+
+assert.commandWorked( m.getDB( "local" ).repairDatabase() );
+assert.eq.automsg( "c", "m.getDB( 'local' ).oplog.$main.count()" );
diff --git a/mongo.xcodeproj/project.pbxproj b/mongo.xcodeproj/project.pbxproj
index 0ed3d333972..c90892e1e9d 100644
--- a/mongo.xcodeproj/project.pbxproj
+++ b/mongo.xcodeproj/project.pbxproj
@@ -462,6 +462,7 @@
938E639B110FC66900A8760A /* auth1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = auth1.js; sourceTree = "<group>"; };
938E63D0110FC96B00A8760A /* auth2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = auth2.js; sourceTree = "<group>"; };
9391C9DD1120F9D300292B19 /* newcollection.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = newcollection.js; sourceTree = "<group>"; };
+ 939693B511BEBAAA0069E3E5 /* repair.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repair.js; sourceTree = "<group>"; };
93A13A210F4620A500AF1B0D /* commands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commands.cpp; sourceTree = "<group>"; };
93A13A230F4620A500AF1B0D /* config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = config.cpp; sourceTree = "<group>"; };
93A13A240F4620A500AF1B0D /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
@@ -1116,6 +1117,7 @@
934BEC5010DFFA9600178102 /* repl */ = {
isa = PBXGroup;
children = (
+ 939693B511BEBAAA0069E3E5 /* repair.js */,
93BDCE92115817210097FE87 /* pair7.js */,
93BDCE401157E7280097FE87 /* repl10.js */,
93BDCE411157E7280097FE87 /* repl11.js */,
diff --git a/shell/utils.js b/shell/utils.js
index 0fd4d69a9a5..b4d177063cd 100644
--- a/shell/utils.js
+++ b/shell/utils.js
@@ -32,6 +32,10 @@ assert = function( b , msg ){
doassert( "assert failed : " + msg );
}
+assert.automsg = function( b ) {
+ assert( eval( b ), b );
+}
+
assert._debug = false;
assert.eq = function( a , b , msg ){
@@ -793,37 +797,37 @@ shellHelper = function( command , rest , shouldPrint ){
shellPrintHelper( res );
}
return res;
-}
-
-help = shellHelper.help = function (x) {
- if (x == "admin") {
- print("\tls([path]) list files");
- print("\tpwd() returns current directory");
- print("\tlistFiles([path]) returns file list");
- print("\tremoveFile(f) delete a file");
- return;
- }
- if (x == "test") {
- print("\tstartMongodEmpty(args) DELETES DATA DIR and then starts mongod");
- print("\t returns a connection to the new server");
- print("\tstartMongodTest() DELETES DATA DIR");
- print("\t automatically picks port #s starting at 27000 and increasing");
- print("\t or you can specify the port as the first arg");
- print("\t dir is /data/db/<port>/ if not specified as the 2nd arg");
- print("\t returns a connection to the new server");
- return;
- }
- print("\t" + "show dbs show database names");
- print("\t" + "show collections show collections in current database");
- print("\t" + "show users show users in current database");
- print("\t" + "show profile show most recent system.profile entries with time >= 1ms");
- print("\t" + "use <db name> set curent database to <db name>");
- print("\t" + "db.help() help on DB methods");
- print("\t" + "db.foo.help() help on collection methods");
- print("\t" + "db.foo.find() list objects in collection foo");
- print("\t" + "db.foo.find( { a : 1 } ) list objects in foo where a == 1");
- print("\t" + "it result of the last line evaluated; use to further iterate");
- print("\t" + "exit quit the mongo shell");
+}
+
+help = shellHelper.help = function (x) {
+ if (x == "admin") {
+ print("\tls([path]) list files");
+ print("\tpwd() returns current directory");
+ print("\tlistFiles([path]) returns file list");
+ print("\tremoveFile(f) delete a file");
+ return;
+ }
+ if (x == "test") {
+ print("\tstartMongodEmpty(args) DELETES DATA DIR and then starts mongod");
+ print("\t returns a connection to the new server");
+ print("\tstartMongodTest() DELETES DATA DIR");
+ print("\t automatically picks port #s starting at 27000 and increasing");
+ print("\t or you can specify the port as the first arg");
+ print("\t dir is /data/db/<port>/ if not specified as the 2nd arg");
+ print("\t returns a connection to the new server");
+ return;
+ }
+ print("\t" + "show dbs show database names");
+ print("\t" + "show collections show collections in current database");
+ print("\t" + "show users show users in current database");
+ print("\t" + "show profile show most recent system.profile entries with time >= 1ms");
+ print("\t" + "use <db name> set curent database to <db name>");
+ print("\t" + "db.help() help on DB methods");
+ print("\t" + "db.foo.help() help on collection methods");
+ print("\t" + "db.foo.find() list objects in collection foo");
+ print("\t" + "db.foo.find( { a : 1 } ) list objects in foo where a == 1");
+ print("\t" + "it result of the last line evaluated; use to further iterate");
+ print("\t" + "exit quit the mongo shell");
}
shellHelper.use = function( dbname ){