mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-29 16:47:28 +01:00
SERVER-426 make repair path configurable
This commit is contained in:
parent
1664c3da4f
commit
3b4a0b04dd
24
db/db.cpp
24
db/db.cpp
@ -58,6 +58,8 @@ namespace mongo {
|
|||||||
extern int diagLogging;
|
extern int diagLogging;
|
||||||
extern int lenForNewNsFiles;
|
extern int lenForNewNsFiles;
|
||||||
extern int lockFile;
|
extern int lockFile;
|
||||||
|
|
||||||
|
extern string repairpath;
|
||||||
|
|
||||||
void setupSignals();
|
void setupSignals();
|
||||||
void closeAllSockets();
|
void closeAllSockets();
|
||||||
@ -462,10 +464,17 @@ namespace mongo {
|
|||||||
|
|
||||||
show_32_warning();
|
show_32_warning();
|
||||||
|
|
||||||
stringstream ss;
|
{
|
||||||
ss << "dbpath (" << dbpath << ") does not exist";
|
stringstream ss;
|
||||||
massert( 10296 , ss.str().c_str(), boost::filesystem::exists( dbpath ) );
|
ss << "dbpath (" << dbpath << ") does not exist";
|
||||||
|
massert( 10296 , ss.str().c_str(), boost::filesystem::exists( dbpath ) );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
stringstream ss;
|
||||||
|
ss << "repairpath (" << repairpath << ") does not exist";
|
||||||
|
massert( 12590 , ss.str().c_str(), boost::filesystem::exists( repairpath ) );
|
||||||
|
}
|
||||||
|
|
||||||
acquirePathLock();
|
acquirePathLock();
|
||||||
remove_all( dbpath + "/_tmp/" );
|
remove_all( dbpath + "/_tmp/" );
|
||||||
|
|
||||||
@ -593,6 +602,7 @@ int main(int argc, char* argv[], char *envp[] )
|
|||||||
("quiet", "quieter output")
|
("quiet", "quieter output")
|
||||||
("logpath", po::value<string>() , "file to send all output to instead of stdout" )
|
("logpath", po::value<string>() , "file to send all output to instead of stdout" )
|
||||||
("logappend" , "appnd to logpath instead of over-writing" )
|
("logappend" , "appnd to logpath instead of over-writing" )
|
||||||
|
("repairpath", po::value<string>() , "root directory for repair files - defaults to dbpath" )
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
("fork" , "fork server process" )
|
("fork" , "fork server process" )
|
||||||
#endif
|
#endif
|
||||||
@ -794,6 +804,12 @@ int main(int argc, char* argv[], char *envp[] )
|
|||||||
uassert( 10033 , "logpath has to be non-zero" , lp.size() );
|
uassert( 10033 , "logpath has to be non-zero" , lp.size() );
|
||||||
initLogging( lp , params.count( "logappend" ) );
|
initLogging( lp , params.count( "logappend" ) );
|
||||||
}
|
}
|
||||||
|
if (params.count("repairpath")) {
|
||||||
|
repairpath = params["repairpath"].as<string>();
|
||||||
|
uassert( 12589, "repairpath has to be non-zero", repairpath.size() );
|
||||||
|
} else {
|
||||||
|
repairpath = dbpath;
|
||||||
|
}
|
||||||
if (params.count("nocursors")) {
|
if (params.count("nocursors")) {
|
||||||
useCursors = false;
|
useCursors = false;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ namespace mongo {
|
|||||||
/* ----------------------------------------- */
|
/* ----------------------------------------- */
|
||||||
|
|
||||||
string dbpath = "/data/db/";
|
string dbpath = "/data/db/";
|
||||||
|
string repairpath;
|
||||||
|
|
||||||
DataFileMgr theDataFileMgr;
|
DataFileMgr theDataFileMgr;
|
||||||
DatabaseHolder dbHolder;
|
DatabaseHolder dbHolder;
|
||||||
@ -1571,14 +1572,14 @@ namespace mongo {
|
|||||||
|
|
||||||
// generate a directory name for storing temp data files
|
// generate a directory name for storing temp data files
|
||||||
Path uniqueReservedPath( const char *prefix ) {
|
Path uniqueReservedPath( const char *prefix ) {
|
||||||
Path dbPath = Path( dbpath );
|
Path repairPath = Path( repairpath );
|
||||||
Path reservedPath;
|
Path reservedPath;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
do {
|
do {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << prefix << "_repairDatabase_" << i++;
|
ss << prefix << "_repairDatabase_" << i++;
|
||||||
reservedPath = dbPath / ss.str();
|
reservedPath = repairPath / ss.str();
|
||||||
BOOST_CHECK_EXCEPTION( exists = boost::filesystem::exists( reservedPath ) );
|
BOOST_CHECK_EXCEPTION( exists = boost::filesystem::exists( reservedPath ) );
|
||||||
} while ( exists );
|
} while ( exists );
|
||||||
return reservedPath;
|
return reservedPath;
|
||||||
|
30
jstests/disk/repair.js
Normal file
30
jstests/disk/repair.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
var baseName = "jstests_disk_repair";
|
||||||
|
|
||||||
|
port = allocatePorts( 1 )[ 0 ];
|
||||||
|
dbpath = "/data/db/" + baseName + "/";
|
||||||
|
repairpath = dbpath + "repairDir/"
|
||||||
|
|
||||||
|
resetDbpath( dbpath );
|
||||||
|
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} );
|
||||||
|
|
||||||
|
escape = function( s ) {
|
||||||
|
ret = "";
|
||||||
|
for( i in s ) {
|
||||||
|
if ( s[ i ] == "/" ) {
|
||||||
|
ret += "\/";
|
||||||
|
} else {
|
||||||
|
ret += s[ i ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
files = listFiles( dbpath );
|
||||||
|
for( f in files ) {
|
||||||
|
assert( ! new RegExp( "^" + dbpath + "backup_" ).test( files[ f ].name ), "backup dir in dbpath" );
|
||||||
|
}
|
@ -421,6 +421,7 @@
|
|||||||
938A7A480F54873600FB7A07 /* reccache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reccache.h; sourceTree = "<group>"; };
|
938A7A480F54873600FB7A07 /* reccache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reccache.h; sourceTree = "<group>"; };
|
||||||
938A7A490F54873600FB7A07 /* reci.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reci.h; sourceTree = "<group>"; };
|
938A7A490F54873600FB7A07 /* reci.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reci.h; sourceTree = "<group>"; };
|
||||||
938A7A4A0F54873600FB7A07 /* recstore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = recstore.h; sourceTree = "<group>"; };
|
938A7A4A0F54873600FB7A07 /* recstore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = recstore.h; sourceTree = "<group>"; };
|
||||||
|
938E5EB3110E1ED700A8760A /* 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>"; };
|
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>"; };
|
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>"; };
|
93A13A240F4620A500AF1B0D /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
||||||
@ -960,6 +961,7 @@
|
|||||||
934BEBCD10DFFA9600178102 /* disk */ = {
|
934BEBCD10DFFA9600178102 /* disk */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
938E5EB3110E1ED700A8760A /* repair.js */,
|
||||||
935C941B1106709800439EB1 /* preallocate.js */,
|
935C941B1106709800439EB1 /* preallocate.js */,
|
||||||
934BEBCE10DFFA9600178102 /* dbNoCreate.js */,
|
934BEBCE10DFFA9600178102 /* dbNoCreate.js */,
|
||||||
934BEBCF10DFFA9600178102 /* diskfull.js */,
|
934BEBCF10DFFA9600178102 /* diskfull.js */,
|
||||||
|
Loading…
Reference in New Issue
Block a user