Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22c7c88d01 | ||
|
|
5bd47701aa | ||
|
|
5ab9c9b6a9 | ||
|
|
672fda4244 | ||
|
|
c0acb04e0f | ||
|
|
2fd67aca84 | ||
|
|
fca1962ce4 | ||
|
|
84eab5e950 | ||
|
|
6e44c36341 | ||
|
|
639c39189f | ||
|
|
7c4cd36d0a | ||
|
|
dee49ac080 | ||
|
|
bec48b040a | ||
|
|
dfe8582685 | ||
|
|
06279cde9a | ||
|
|
677a095c22 | ||
|
|
b2973e7cc3 | ||
|
|
447c9df927 | ||
|
|
063f651c6b | ||
|
|
97515db5b8 | ||
|
|
b90ccb6652 | ||
|
|
c0a685292a | ||
|
|
cc206ecdf6 | ||
|
|
084eb0c7f2 | ||
|
|
5cf582d3d9 | ||
|
|
4a7c73f5e2 | ||
|
|
ee388151a7 | ||
|
|
8e3d106320 | ||
|
|
76d4703561 | ||
|
|
1d82d20390 | ||
|
|
de365ac8eb | ||
|
|
a05b907fc4 | ||
|
|
fcb6a16b48 | ||
|
|
074553298d | ||
|
|
92b27770be | ||
|
|
c62aa841a2 | ||
|
|
5ded448a90 |
25
SConstruct
25
SConstruct
@@ -843,6 +843,8 @@ def concatjs(target, source, env):
|
||||
|
||||
fullSource = ""
|
||||
|
||||
first = True
|
||||
|
||||
for s in source:
|
||||
f = open( str(s) , 'r' )
|
||||
for l in f:
|
||||
@@ -850,8 +852,21 @@ def concatjs(target, source, env):
|
||||
if len ( l ) == 0:
|
||||
continue
|
||||
|
||||
fullSource += l + "\n"
|
||||
if l == "}":
|
||||
fullSource += "}"
|
||||
continue
|
||||
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
fullSource += "\n"
|
||||
|
||||
fullSource += l
|
||||
|
||||
fullSource += "\n"
|
||||
|
||||
fullSource = re.compile( r'/\*\*.*?\*/' , re.M | re.S ).sub( "" , fullSource )
|
||||
|
||||
out = open( outFile , 'w' )
|
||||
out.write( fullSource )
|
||||
|
||||
@@ -1110,7 +1125,6 @@ if not onlyServer and not noshell:
|
||||
addSmoketest( "smokeSharding", [ "mongo", "mongod", "mongos" ], jsDirTestSpec( "sharding" ) )
|
||||
addSmoketest( "smokeJsPerf", [ "mongo" ], runShellTest )
|
||||
addSmoketest( "smokeQuota", [ "mongo" ], runShellTest )
|
||||
|
||||
if windows: # this test doesn't work on windows in v1.2.x
|
||||
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], [] )
|
||||
else:
|
||||
@@ -1125,7 +1139,7 @@ def startMongodForTests( env, target, source ):
|
||||
global mongod
|
||||
if mongodForTests:
|
||||
return
|
||||
mongodForTestsPort = "40000"
|
||||
mongodForTestsPort = "32000"
|
||||
import os
|
||||
ensureTestDirs()
|
||||
dirName = "/data/db/sconsTests/"
|
||||
@@ -1164,6 +1178,11 @@ testEnv.Alias( "startMongod", [add_exe("mongod")], [startMongodForTests] );
|
||||
testEnv.AlwaysBuild( "startMongod" );
|
||||
testEnv.SideEffect( "dummySmokeSideEffect", "startMongod" )
|
||||
|
||||
testEnv.Alias( "startMongodSmallOplog", [add_exe("mongod")], [startMongodForTests] );
|
||||
testEnv.AlwaysBuild( "startMongodSmallOplog" );
|
||||
testEnv.SideEffect( "dummySmokeSideEffect", "startMongodSmallOplog" )
|
||||
|
||||
|
||||
def addMongodReqTargets( env, target, source ):
|
||||
mongodReqTargets = [ "smokeClient", "smokeJs", "smokeQuota" ]
|
||||
for target in mongodReqTargets:
|
||||
|
||||
@@ -39,7 +39,9 @@ def foundxulrunner( env , options ):
|
||||
env.Prepend( RPATH=[ libroot ] )
|
||||
|
||||
env.Prepend( CPPPATH=[ incroot + "stable/" ,
|
||||
incroot + "unstable/" ] )
|
||||
incroot + "unstable/" ,
|
||||
incroot ] )
|
||||
env.Prepend( CPPPATH=[ "/usr/include/nspr/" ] )
|
||||
|
||||
env.Append( CPPDEFINES=[ "XULRUNNER" , "OLDJS" ] )
|
||||
if best.find( "1.9.0" ) >= 0 or best.endswith("1.9"):
|
||||
|
||||
13
db/db.cpp
13
db/db.cpp
@@ -65,6 +65,8 @@ namespace mongo {
|
||||
void pairWith(const char *remoteEnd, const char *arb);
|
||||
void setRecCacheSize(unsigned MB);
|
||||
|
||||
void exitCleanly( ExitCode code );
|
||||
|
||||
const char *ourgetns() {
|
||||
Client *c = currentClient.get();
|
||||
return c ? c->ns() : "";
|
||||
@@ -224,6 +226,9 @@ namespace mongo {
|
||||
problem() << "SocketException in connThread, closing client connection" << endl;
|
||||
dbMsgPort.shutdown();
|
||||
}
|
||||
catch ( const ClockSkewException &e ) {
|
||||
exitCleanly( EXIT_CLOCK_SKEW );
|
||||
}
|
||||
catch ( std::exception &e ) {
|
||||
problem() << "Uncaught std::exception: " << e.what() << ", terminating" << endl;
|
||||
dbexit( EXIT_UNCAUGHT );
|
||||
@@ -943,13 +948,13 @@ namespace mongo {
|
||||
|
||||
#undef out
|
||||
|
||||
void exitCleanly() {
|
||||
void exitCleanly( ExitCode code ) {
|
||||
goingAway = true;
|
||||
killCurrentOp = 1;
|
||||
{
|
||||
dblock lk;
|
||||
log() << "now exiting" << endl;
|
||||
dbexit( EXIT_KILL );
|
||||
dbexit( code );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,7 +1000,7 @@ namespace mongo {
|
||||
int x;
|
||||
sigwait( &asyncSignals, &x );
|
||||
log() << "got kill or ctrl c signal " << x << " (" << strsignal( x ) << "), will terminate after current cmd ends" << endl;
|
||||
exitCleanly();
|
||||
exitCleanly( EXIT_KILL );
|
||||
}
|
||||
|
||||
void setupSignals() {
|
||||
@@ -1018,7 +1023,7 @@ namespace mongo {
|
||||
#else
|
||||
void ctrlCTerminate() {
|
||||
log() << "got kill or ctrl c signal, will terminate after current cmd ends" << endl;
|
||||
exitCleanly();
|
||||
exitCleanly( EXIT_KILL );
|
||||
}
|
||||
BOOL CtrlHandler( DWORD fdwCtrlType )
|
||||
{
|
||||
|
||||
@@ -1281,7 +1281,32 @@ namespace mongo {
|
||||
|
||||
} distinctCmd;
|
||||
|
||||
|
||||
/* For testing only, not for general use */
|
||||
class GodInsert : public Command {
|
||||
public:
|
||||
GodInsert() : Command( "godinsert" ) { }
|
||||
virtual bool logTheOp() {
|
||||
return true;
|
||||
}
|
||||
virtual bool slaveOk() {
|
||||
return false;
|
||||
}
|
||||
virtual bool requiresAuth() {
|
||||
return true;
|
||||
}
|
||||
virtual void help( stringstream &help ) const {
|
||||
help << "[for testing only]";
|
||||
}
|
||||
virtual bool run(const char *dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
||||
string coll = cmdObj[ "godinsert" ].valuestrsafe();
|
||||
uassert( "godinsert must specify a collection", !coll.empty() );
|
||||
string ns = nsToClient( dbname ) + "." + coll;
|
||||
BSONObj obj = cmdObj[ "obj" ].embeddedObjectUserCheck();
|
||||
DiskLoc loc = theDataFileMgr.insert( ns.c_str(), obj, true );
|
||||
return true;
|
||||
}
|
||||
} cmdGodInsert;
|
||||
|
||||
extern map<string,Command*> *commands;
|
||||
|
||||
/* TODO make these all command objects -- legacy stuff here
|
||||
|
||||
12
db/jsobj.cpp
12
db/jsobj.cpp
@@ -608,11 +608,15 @@ namespace mongo {
|
||||
case DBRef:
|
||||
case Code:
|
||||
case Symbol:
|
||||
case String:
|
||||
massert( "Invalid dbref/code/string/symbol size",
|
||||
valuestrsize() > 0 &&
|
||||
valuestrsize() - 1 == strnlen( valuestr(), valuestrsize() ) );
|
||||
case String: {
|
||||
int x = valuestrsize();
|
||||
if ( x > 0 && valuestr()[x-1] == 0 )
|
||||
return;
|
||||
stringstream buf;
|
||||
buf << "Invalid dbref/code/string/symbol size: " << x;
|
||||
massert( buf.str() , 0 );
|
||||
break;
|
||||
}
|
||||
case CodeWScope: {
|
||||
int totalSize = *( int * )( value() );
|
||||
massert( "Invalid CodeWScope size", totalSize >= 8 );
|
||||
|
||||
@@ -103,7 +103,6 @@ namespace mongo {
|
||||
if ( ! _needRecord ){
|
||||
return true;
|
||||
}
|
||||
|
||||
return _recordMatcher.matches(recLoc.rec());
|
||||
}
|
||||
|
||||
|
||||
11
db/query.cpp
11
db/query.cpp
@@ -481,12 +481,17 @@ namespace mongo {
|
||||
findingStartCursor_ = new ClientCursor();
|
||||
findingStartCursor_->c = qp().newReverseCursor();
|
||||
findingStartCursor_->ns = qp().ns();
|
||||
BSONElement tsElt = qp().query()[ "ts" ];
|
||||
massert( "no ts field in query", !tsElt.eoo() );
|
||||
BSONObjBuilder b;
|
||||
b.append( tsElt );
|
||||
BSONObj tsQuery = b.obj();
|
||||
matcher_.reset(new KeyValJSMatcher(tsQuery, qp().indexKey()));
|
||||
} else {
|
||||
c_ = qp().newCursor();
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
}
|
||||
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
|
||||
if ( qp().scanAndOrderRequired() ) {
|
||||
ordering_ = true;
|
||||
so_.reset( new ScanAndOrder( ntoskip_, ntoreturn_, order_ ) );
|
||||
@@ -498,9 +503,11 @@ namespace mongo {
|
||||
if ( !findingStartCursor_ || !findingStartCursor_->c->ok() ) {
|
||||
findingStart_ = false;
|
||||
c_ = qp().newCursor();
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
} else if ( !matcher_->matches( findingStartCursor_->c->currKey(), findingStartCursor_->c->currLoc() ) ) {
|
||||
findingStart_ = false;
|
||||
c_ = qp().newCursor( findingStartCursor_->c->currLoc() );
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
} else {
|
||||
findingStartCursor_->c->advance();
|
||||
RARELY {
|
||||
|
||||
14
db/repl.cpp
14
db/repl.cpp
@@ -981,7 +981,11 @@ namespace mongo {
|
||||
|
||||
void ReplSource::syncToTailOfRemoteLog() {
|
||||
string _ns = ns();
|
||||
BSONObj last = conn->findOne( _ns.c_str(), Query().sort( BSON( "$natural" << -1 ) ) );
|
||||
BSONObjBuilder b;
|
||||
if ( !only.empty() ) {
|
||||
b.appendRegex("ns", string("^") + only);
|
||||
}
|
||||
BSONObj last = conn->findOne( _ns.c_str(), Query( b.done() ).sort( BSON( "$natural" << -1 ) ) );
|
||||
if ( !last.isEmpty() ) {
|
||||
BSONElement ts = last.findElement( "ts" );
|
||||
massert( "non Date ts found", ts.type() == Date || ts.type() == Timestamp );
|
||||
@@ -1640,8 +1644,14 @@ namespace mongo {
|
||||
const char * ns = "local.oplog.$main";
|
||||
setClient(ns);
|
||||
|
||||
if ( nsdetails( ns ) )
|
||||
if ( nsdetails( ns ) ) {
|
||||
DBDirectClient c;
|
||||
BSONObj lastOp = c.findOne( ns, Query().sort( BSON( "$natural" << -1 ) ) );
|
||||
if ( !lastOp.isEmpty() ) {
|
||||
OpTime::setLast( lastOp[ "ts" ].date() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* create an oplog collection, if it doesn't yet exist. */
|
||||
BSONObjBuilder b;
|
||||
|
||||
@@ -339,8 +339,9 @@ namespace JsobjTests {
|
||||
}
|
||||
BSONObj invalid() const {
|
||||
BSONObj ret = valid();
|
||||
set( ret, 0, get( ret, 0 ) + 1 );
|
||||
set( ret, 7, get( ret, 7 ) + 1 );
|
||||
ASSERT_EQUALS( ret.firstElement().valuestr()[0] , 'b' );
|
||||
ASSERT_EQUALS( ret.firstElement().valuestr()[1] , 0 );
|
||||
((char*)ret.firstElement().valuestr())[1] = 1;
|
||||
return ret.copy();
|
||||
}
|
||||
};
|
||||
@@ -391,32 +392,6 @@ namespace JsobjTests {
|
||||
};
|
||||
};
|
||||
|
||||
class WrongSymbolSize : public Base {
|
||||
BSONObj valid() const {
|
||||
return fromjson( "{\"a\":\"b\"}" );
|
||||
}
|
||||
BSONObj invalid() const {
|
||||
BSONObj ret = valid();
|
||||
set( ret, 4, Symbol );
|
||||
set( ret, 0, get( ret, 0 ) + 1 );
|
||||
set( ret, 7, get( ret, 7 ) + 1 );
|
||||
return ret.copy();
|
||||
}
|
||||
};
|
||||
|
||||
class WrongCodeSize : public Base {
|
||||
BSONObj valid() const {
|
||||
return fromjson( "{\"a\":\"b\"}" );
|
||||
}
|
||||
BSONObj invalid() const {
|
||||
BSONObj ret = valid();
|
||||
set( ret, 4, Code );
|
||||
set( ret, 0, get( ret, 0 ) + 1 );
|
||||
set( ret, 7, get( ret, 7 ) + 1 );
|
||||
return ret.copy();
|
||||
}
|
||||
};
|
||||
|
||||
class NoFieldNameEnd : public Base {
|
||||
BSONObj valid() const {
|
||||
return fromjson( "{\"a\":1}" );
|
||||
@@ -1248,8 +1223,6 @@ namespace JsobjTests {
|
||||
add< BSONObjTests::Validation::NegativeStringSize >();
|
||||
add< BSONObjTests::Validation::WrongSubobjectSize >();
|
||||
add< BSONObjTests::Validation::WrongDbrefNsSize >();
|
||||
add< BSONObjTests::Validation::WrongSymbolSize >();
|
||||
add< BSONObjTests::Validation::WrongCodeSize >();
|
||||
add< BSONObjTests::Validation::NoFieldNameEnd >();
|
||||
add< BSONObjTests::Validation::BadRegex >();
|
||||
add< BSONObjTests::Validation::BadRegexOptions >();
|
||||
|
||||
@@ -288,13 +288,13 @@ namespace QueryTests {
|
||||
}
|
||||
void run() {
|
||||
const char *ns = "unittests.querytests.OplogReplayMode";
|
||||
insert( ns, BSON( "a" << 3 ) );
|
||||
insert( ns, BSON( "a" << 0 ) );
|
||||
insert( ns, BSON( "a" << 1 ) );
|
||||
insert( ns, BSON( "a" << 2 ) );
|
||||
auto_ptr< DBClientCursor > c = client().query( ns, QUERY( "a" << GT << 1 ).hint( BSON( "$natural" << 1 ) ), 0, 0, 0, Option_OplogReplay );
|
||||
insert( ns, BSON( "ts" << 3 ) );
|
||||
insert( ns, BSON( "ts" << 0 ) );
|
||||
insert( ns, BSON( "ts" << 1 ) );
|
||||
insert( ns, BSON( "ts" << 2 ) );
|
||||
auto_ptr< DBClientCursor > c = client().query( ns, QUERY( "ts" << GT << 1 ).hint( BSON( "$natural" << 1 ) ), 0, 0, 0, Option_OplogReplay );
|
||||
ASSERT( c->more() );
|
||||
ASSERT_EQUALS( 2, c->next().getIntField( "a" ) );
|
||||
ASSERT_EQUALS( 2, c->next().getIntField( "ts" ) );
|
||||
ASSERT( !c->more() );
|
||||
}
|
||||
};
|
||||
|
||||
14
debian/changelog
vendored
14
debian/changelog
vendored
@@ -1,3 +1,17 @@
|
||||
mongodb (1.2.5) unsable; urgency=low
|
||||
|
||||
* replication clock skew fix
|
||||
|
||||
-- Richard Kreuter <richard@10gen.com> Fri, 05 Feb 2010 16:56:28 -0500
|
||||
|
||||
mongodb (1.2.4) unsable; urgency=low
|
||||
|
||||
* shell fix
|
||||
* replication only fix
|
||||
|
||||
-- Richard Kreuter <richard@10gen.com> Fri, 05 Feb 2010 16:56:28 -0500
|
||||
|
||||
|
||||
mongodb (1.2.3) unsable; urgency=low
|
||||
|
||||
* munged debian files
|
||||
|
||||
4
debian/init.d
vendored
4
debian/init.d
vendored
@@ -68,6 +68,10 @@ if test ! -x $DAEMON; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test "x$ENABLE_MONGODB" != "xyes"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test ! -x $DATA; then
|
||||
mkdir $DATA || exit 0
|
||||
fi
|
||||
|
||||
9
debian/mongodb.upstart
vendored
9
debian/mongodb.upstart
vendored
@@ -5,6 +5,11 @@ pre-start script
|
||||
mkdir -p /var/log/mongodb/
|
||||
end script
|
||||
|
||||
start on runlevel [345]
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [06]
|
||||
|
||||
exec su -c "/usr/bin/mongod --config /etc/mongodb.conf" -s "/bin/sh" mongodb
|
||||
script
|
||||
ENABLE_MONGODB="yes"
|
||||
if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
|
||||
if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start --quiet --chuid mongodb --exec /usr/bin/mongod -- --config /etc/mongodb.conf; fi
|
||||
end script
|
||||
|
||||
4
debian/postinst
vendored
4
debian/postinst
vendored
@@ -29,11 +29,11 @@ case "$1" in
|
||||
|
||||
# create db -- note: this should agree with dbpath in mongodb.conf
|
||||
mkdir -p /var/lib/mongodb
|
||||
chown mongodb:mongodb /var/lib/mongodb
|
||||
chown -R mongodb:mongodb /var/lib/mongodb
|
||||
|
||||
# create logdir -- note: this should agree with logpath in mongodb.conf
|
||||
mkdir -p /var/log/mongodb
|
||||
chown mongodb:mongodb /var/log/mongodb
|
||||
chown -R mongodb:mongodb /var/log/mongodb
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
|
||||
5
debian/rules
vendored
5
debian/rules
vendored
@@ -35,7 +35,10 @@ clean:
|
||||
dh_testroot
|
||||
rm -f build-stamp configure-stamp
|
||||
|
||||
scons -c
|
||||
# FIXME: scons freaks out at the presence of target files
|
||||
# under debian/mongodb.
|
||||
#scons -c
|
||||
rm -rf $(CURDIR)/debian/mongodb
|
||||
rm -f config.log
|
||||
rm -f mongo
|
||||
rm -f mongod
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = MongoDB
|
||||
PROJECT_NUMBER = 1.2.3
|
||||
PROJECT_NUMBER = 1.2.5
|
||||
OUTPUT_DIRECTORY = docs
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
53
jstests/repl/master1.js
Normal file
53
jstests/repl/master1.js
Normal file
@@ -0,0 +1,53 @@
|
||||
// Test handling of clock skew and optimes across mongod instances
|
||||
|
||||
if ( typeof( BinData ) != "undefined" ) { // don't run in v8
|
||||
|
||||
var baseName = "jstests_repl_master1test";
|
||||
|
||||
oplog = function() {
|
||||
return m.getDB( "local" ).oplog.$main;
|
||||
}
|
||||
|
||||
lastop = function() {
|
||||
return oplog().find().sort( {$natural:-1} ).next();
|
||||
}
|
||||
|
||||
am = function() {
|
||||
return m.getDB( baseName ).a;
|
||||
}
|
||||
|
||||
rt = new ReplTest( baseName );
|
||||
|
||||
m = rt.start( true );
|
||||
|
||||
am().save( {} );
|
||||
assert.eq( "i", lastop().op );
|
||||
|
||||
op = lastop();
|
||||
printjson( op );
|
||||
op.ts.t = op.ts.t + 600000 // 10 minutes
|
||||
m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} );
|
||||
|
||||
rt.stop( true );
|
||||
m = rt.start( true, null, true );
|
||||
|
||||
assert.eq( op.ts.t, lastop().ts.t );
|
||||
am().save( {} );
|
||||
assert.eq( op.ts.t, lastop().ts.t );
|
||||
assert.eq( op.ts.i + 1, lastop().ts.i );
|
||||
|
||||
op = lastop();
|
||||
printjson( op );
|
||||
op.ts.i = Math.pow(2,31);
|
||||
printjson( op );
|
||||
m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} );
|
||||
|
||||
rt.stop( true );
|
||||
m = rt.start( true, null, true );
|
||||
assert.eq( op.ts.i, lastop().ts.i );
|
||||
am().save( {} );
|
||||
sleep( 3000 ); // make sure dies on its own before stop() called
|
||||
|
||||
assert.eq( 47 /*EXIT_CLOCK_SKEW*/, rt.stop( true ) );
|
||||
|
||||
}
|
||||
@@ -226,6 +226,8 @@ doTest4 = function( signal ) {
|
||||
// now can only talk to arbiter
|
||||
pair.start( true );
|
||||
pair.waitForSteadyState( [ 1, 1 ], null, true );
|
||||
|
||||
ports.forEach( function( x ) { stopMongoProgram( x ); } );
|
||||
}
|
||||
|
||||
doTest1();
|
||||
|
||||
@@ -28,6 +28,14 @@ doTest = function() {
|
||||
printjson( s.getDBNames() );
|
||||
assert.eq( -1, s.getDBNames().indexOf( "b" ) );
|
||||
assert.eq( 0, s.getDB( "b" ).b.find().count() );
|
||||
|
||||
stopMongod( ports[ 1 ] );
|
||||
|
||||
cm.save( { x:3 } );
|
||||
bm.save( { x:4 } );
|
||||
|
||||
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--only", "c", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
soonCount( "c", "c", 2 );
|
||||
}
|
||||
|
||||
doTest();
|
||||
|
||||
@@ -12,30 +12,37 @@
|
||||
|
||||
# things from mongod.conf get there by mongod reading it
|
||||
|
||||
|
||||
|
||||
OPTIONS=" -f /etc/mongod.conf"
|
||||
SYSCONFIG="/etc/sysconfig/mongod"
|
||||
|
||||
mongod=${MONGOD-/usr/bin/mongod}
|
||||
pidfile=${PIDFILE-/var/run/mongod.pid}
|
||||
lockfile=${LOCKFILE-/var/lock/subsys/mongod}
|
||||
|
||||
MONGO_USER=mongod
|
||||
MONGO_GROUP=mongod
|
||||
|
||||
. "$SYSCONFIG" || true
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n $"Starting mongod: "
|
||||
#daemon --pidfile=${pidfile} $mongod $OPTIONS > /var/log/mongod
|
||||
$mongod $OPTIONS > /var/log/mongod 2>&1 &
|
||||
daemon --user "$MONGO_USER" $mongod $OPTIONS
|
||||
RETVAL=$?
|
||||
[ $RETVAL = 0 ] && touch ${lockfile}
|
||||
echo OK
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod && success
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
echo -n $"Stopping mongod: "
|
||||
#killproc -p ${pidfile} -d 10 $mongod
|
||||
#RETVAL=$?
|
||||
killall mongod > /dev/null 2>&1
|
||||
#[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
|
||||
echo OK
|
||||
killproc -p /var/lib/mongo/mongod.lock -t30 -TERM /usr/bin/mongod
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod && success
|
||||
}
|
||||
|
||||
restart () {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
ulimit -n 12000
|
||||
@@ -48,15 +55,17 @@ case "$1" in
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
restart|reload|force-reload)
|
||||
restart
|
||||
;;
|
||||
condrestart)
|
||||
[ -f /var/lock/subsys/mongodb ] && restart || :
|
||||
;;
|
||||
status)
|
||||
status $mongod
|
||||
;;
|
||||
# status)
|
||||
# status -p ${pidfile} $mongod
|
||||
# ;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart}"
|
||||
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: mongo
|
||||
Version: 1.2.3
|
||||
Version: 1.2.5
|
||||
Release: mongodb_1%{?dist}
|
||||
Summary: mongo client shell and tools
|
||||
License: AGPL 3.0
|
||||
@@ -23,6 +23,7 @@ client utilities.
|
||||
%package server
|
||||
Summary: mongo server, sharding server, and support scripts
|
||||
Group: Applications/Databases
|
||||
Requires: mongo
|
||||
|
||||
%description server
|
||||
Mongo (from "huMONGOus") is a schema-free document-oriented database.
|
||||
@@ -56,17 +57,19 @@ cp rpm/init.d-mongod $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
|
||||
chmod a+x $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
|
||||
mkdir -p $RPM_BUILD_ROOT/etc
|
||||
cp rpm/mongod.conf $RPM_BUILD_ROOT/etc/mongod.conf
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
|
||||
cp rpm/mongod.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/mongod
|
||||
mkdir -p $RPM_BUILD_ROOT/var/lib/mongo
|
||||
mkdir -p $RPM_BUILD_ROOT/var/log
|
||||
touch $RPM_BUILD_ROOT/var/log/mongo
|
||||
mkdir -p $RPM_BUILD_ROOT/var/log/mongo
|
||||
touch $RPM_BUILD_ROOT/var/log/mongo/mongod.log
|
||||
|
||||
%clean
|
||||
scons -c
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%pre server
|
||||
#/usr/sbin/useradd -M -o -r -d /var/mongo -s /bin/bash \
|
||||
# -c "mongod" mongod > /dev/null 2>&1 || :
|
||||
/usr/sbin/useradd -M -r -U -d /var/lib/mongo -s /bin/false \
|
||||
-c mongod mongod > /dev/null 2>&1
|
||||
|
||||
%post server
|
||||
if test $1 = 1
|
||||
@@ -98,10 +101,12 @@ fi
|
||||
%{_bindir}/mongorestore
|
||||
|
||||
%{_mandir}/man1/mongo.1*
|
||||
%{_mandir}/man1/mongod.1*
|
||||
%{_mandir}/man1/mongodump.1*
|
||||
%{_mandir}/man1/mongoexport.1*
|
||||
%{_mandir}/man1/mongofiles.1*
|
||||
%{_mandir}/man1/mongoimport.1*
|
||||
%{_mandir}/man1/mongosniff.1*
|
||||
%{_mandir}/man1/mongorestore.1*
|
||||
|
||||
%files server
|
||||
@@ -114,8 +119,9 @@ fi
|
||||
/etc/rc.d/init.d/mongod
|
||||
/etc/sysconfig/mongod
|
||||
#/etc/rc.d/init.d/mongos
|
||||
%attr(0755,root,root) %dir /var/mongo
|
||||
%attr(0640,root,root) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo
|
||||
%attr(0755,mongod,mongod) %dir /var/lib/mongo
|
||||
%attr(0755,mongod,mongod) %dir /var/log/mongo
|
||||
%attr(0640,mongod,mongod) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo/mongod.log
|
||||
|
||||
%files devel
|
||||
/usr/include/mongo
|
||||
@@ -123,6 +129,8 @@ fi
|
||||
#%{_libdir}/libmongotestfiles.a
|
||||
|
||||
%changelog
|
||||
* Thu Jan 28 2010 Richard M Kreuter <richard@10gen.com>
|
||||
- Minor fixes.
|
||||
|
||||
* Sat Oct 24 2009 Joe Miklojcik <jmiklojcik@shopwiki.com> -
|
||||
- Wrote mongo.spec.
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
# mongo.conf
|
||||
|
||||
#where to log
|
||||
logpath=/var/log/mongod
|
||||
logpath=/var/log/mongo/mongod.log
|
||||
|
||||
# fork and run in background
|
||||
fork = true
|
||||
|
||||
#port = 27017
|
||||
|
||||
|
||||
1
rpm/mongod.sysconfig
Normal file
1
rpm/mongod.sysconfig
Normal file
@@ -0,0 +1 @@
|
||||
# TODO: add relevant configuration stuff here.
|
||||
@@ -39,7 +39,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
boost::thread_specific_ptr<SMScope> currentScope( dontDeleteScope );
|
||||
boost::recursive_mutex smmutex;
|
||||
boost::recursive_mutex &smmutex = *( new boost::recursive_mutex );
|
||||
#define smlock recursive_boostlock ___lk( smmutex );
|
||||
|
||||
#define GETHOLDER(x,o) ((BSONHolder*)JS_GetPrivate( x , o ))
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#endif
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsdate.h"
|
||||
#include "jsregexp.h"
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace mongo {
|
||||
case mongo::Timestamp: {
|
||||
Local<v8::Object> sub = v8::Object::New();
|
||||
|
||||
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "t" ) , v8::Number::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
|
||||
|
||||
o->Set( v8::String::New( f.fieldName() ) , sub );
|
||||
@@ -213,7 +213,7 @@ namespace mongo {
|
||||
case mongo::Timestamp: {
|
||||
Local<v8::Object> sub = v8::Object::New();
|
||||
|
||||
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "t" ) , v8::Number::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
|
||||
|
||||
return sub;
|
||||
|
||||
@@ -113,7 +113,7 @@ ShardingTest = function( testName , numServers , verboseLevel , numMongos ){
|
||||
|
||||
for ( var i=0; i<numServers; i++){
|
||||
var conn = startMongod( { port : 30000 + i , dbpath : "/data/db/" + testName + i ,
|
||||
noprealloc : "" , smallfiles : "" , oplogSize : "2" } );
|
||||
noprealloc : "" , smallfiles : "" , oplogSize : "2" , "nohttpinterface" : ""} );
|
||||
conn.name = "localhost:" + ( 30000 + i );
|
||||
|
||||
this._connections.push( conn );
|
||||
@@ -124,7 +124,7 @@ ShardingTest = function( testName , numServers , verboseLevel , numMongos ){
|
||||
|
||||
|
||||
this._mongos = [];
|
||||
var startMongosPort = 39999;
|
||||
var startMongosPort = 31000;
|
||||
for ( var i=0; i<(numMongos||1); i++ ){
|
||||
var myPort = startMongosPort - i;
|
||||
var conn = startMongos( { port : startMongosPort - i , v : verboseLevel || 0 , configdb : this._configDB } );
|
||||
@@ -173,7 +173,7 @@ ShardingTest.prototype.getOther = function( one ){
|
||||
|
||||
ShardingTest.prototype.stop = function(){
|
||||
for ( var i=0; i<this._mongos.length; i++ ){
|
||||
stopMongoProgram( 39999 - i );
|
||||
stopMongoProgram( 31000 - i );
|
||||
}
|
||||
for ( var i=0; i<this._connections.length; i++){
|
||||
stopMongod( 30000 + i );
|
||||
@@ -599,5 +599,12 @@ ReplTest.prototype.stop = function( master , signal ){
|
||||
this.stop( false );
|
||||
return;
|
||||
}
|
||||
stopMongod( this.getPort( master ) , signal || 15 );
|
||||
return stopMongod( this.getPort( master ) , signal || 15 );
|
||||
}
|
||||
|
||||
allocatePorts = function( n ) {
|
||||
var ret = [];
|
||||
for( var i = 31000; i < 31000 + n; ++i )
|
||||
ret.push( i );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -139,42 +139,6 @@ namespace mongo {
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
BSONObj AllocatePorts( const BSONObj &args ) {
|
||||
uassert( "allocatePorts takes exactly 1 argument", args.nFields() == 1 );
|
||||
uassert( "allocatePorts needs to be passed an integer", args.firstElement().isNumber() );
|
||||
|
||||
int n = int( args.firstElement().number() );
|
||||
|
||||
vector< int > ports;
|
||||
vector< int > sockets;
|
||||
for( int i = 0; i < n; ++i ) {
|
||||
int s = socket( AF_INET, SOCK_STREAM, 0 );
|
||||
assert( s );
|
||||
|
||||
sockaddr_in address;
|
||||
memset(address.sin_zero, 0, sizeof(address.sin_zero));
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_port = 0;
|
||||
address.sin_addr.s_addr = inet_addr( "127.0.0.1" );
|
||||
assert( 0 == ::bind( s, (sockaddr*)&address, sizeof( address ) ) );
|
||||
|
||||
sockaddr_in newAddress;
|
||||
socklen_t len = sizeof( newAddress );
|
||||
assert( 0 == getsockname( s, (sockaddr*)&newAddress, &len ) );
|
||||
ports.push_back( ntohs( newAddress.sin_port ) );
|
||||
sockets.push_back( s );
|
||||
}
|
||||
for( vector< int >::const_iterator i = sockets.begin(); i != sockets.end(); ++i )
|
||||
assert( 0 == close( *i ) );
|
||||
|
||||
sort( ports.begin(), ports.end() );
|
||||
for( unsigned i = 1; i < ports.size(); ++i )
|
||||
massert( "duplicate ports allocated", ports[ i - 1 ] != ports[ i ] );
|
||||
BSONObjBuilder b;
|
||||
b.append( "", ports );
|
||||
return b.obj();
|
||||
}
|
||||
|
||||
map< int, pair< pid_t, int > > dbs;
|
||||
map< pid_t, int > shells;
|
||||
@@ -357,12 +321,13 @@ namespace mongo {
|
||||
return undefined_;
|
||||
}
|
||||
|
||||
void killDb( int port, pid_t _pid, int signal ) {
|
||||
int killDb( int port, pid_t _pid, int signal ) {
|
||||
pid_t pid;
|
||||
int exitCode = 0;
|
||||
if ( port > 0 ) {
|
||||
if( dbs.count( port ) != 1 ) {
|
||||
cout << "No db started on port: " << port << endl;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
pid = dbs[ port ].first;
|
||||
} else {
|
||||
@@ -382,6 +347,7 @@ namespace mongo {
|
||||
}
|
||||
int temp;
|
||||
int ret = waitpid( pid, &temp, WNOHANG );
|
||||
exitCode = WEXITSTATUS( temp );
|
||||
if ( ret == pid )
|
||||
break;
|
||||
sleepms( 1000 );
|
||||
@@ -404,6 +370,8 @@ namespace mongo {
|
||||
if ( i > 4 || signal == SIGKILL ) {
|
||||
sleepms( 4000 ); // allow operating system to reclaim resources
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
int getSignal( const BSONObj &a ) {
|
||||
@@ -422,18 +390,18 @@ namespace mongo {
|
||||
assert( a.nFields() == 1 || a.nFields() == 2 );
|
||||
assert( a.firstElement().isNumber() );
|
||||
int port = int( a.firstElement().number() );
|
||||
killDb( port, 0, getSignal( a ) );
|
||||
int code = killDb( port, 0, getSignal( a ) );
|
||||
cout << "shell: stopped mongo program on port " << port << endl;
|
||||
return undefined_;
|
||||
return BSON( "" << code );
|
||||
}
|
||||
|
||||
BSONObj StopMongoProgramByPid( const BSONObj &a ) {
|
||||
assert( a.nFields() == 1 || a.nFields() == 2 );
|
||||
assert( a.firstElement().isNumber() );
|
||||
int pid = int( a.firstElement().number() );
|
||||
killDb( 0, pid, getSignal( a ) );
|
||||
int code = killDb( 0, pid, getSignal( a ) );
|
||||
cout << "shell: stopped mongo program on pid " << pid << endl;
|
||||
return undefined_;
|
||||
return BSON( "" << code );
|
||||
}
|
||||
|
||||
void KillMongoProgramInstances() {
|
||||
@@ -483,7 +451,6 @@ namespace mongo {
|
||||
scope.injectNative( "version" , JSVersion );
|
||||
scope.injectNative( "hex_md5" , jsmd5 );
|
||||
#if !defined(_WIN32)
|
||||
scope.injectNative( "allocatePorts", AllocatePorts );
|
||||
scope.injectNative( "_startMongoProgram", StartMongoProgram );
|
||||
scope.injectNative( "runMongoProgram", RunMongoProgram );
|
||||
scope.injectNative( "stopMongod", StopMongoProgram );
|
||||
|
||||
@@ -32,6 +32,6 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
const char versionString[] = "1.2.3";
|
||||
const char versionString[] = "1.2.6-pre-";
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
1
stdafx.h
1
stdafx.h
@@ -53,6 +53,7 @@ namespace mongo {
|
||||
EXIT_OOM_MALLOC = 42 ,
|
||||
EXIT_OOM_REALLOC = 43 ,
|
||||
EXIT_FS = 45 ,
|
||||
EXIT_CLOCK_SKEW = 47 ,
|
||||
EXIT_POSSIBLE_CORRUPTION = 60 , // this means we detected a possible corruption situation, like a buf overflow
|
||||
EXIT_UNCAUGHT = 100 , // top level exception that wasn't caught
|
||||
EXIT_TEST = 101 ,
|
||||
|
||||
@@ -242,6 +242,15 @@ namespace mongo {
|
||||
return (xt.sec & 0xfffff) * 1000 + t;
|
||||
}
|
||||
|
||||
struct Date_t {
|
||||
// TODO: make signed (and look for related TODO's)
|
||||
unsigned long long millis;
|
||||
Date_t(): millis(0) {}
|
||||
Date_t(unsigned long long m): millis(m) {}
|
||||
operator unsigned long long&() { return millis; }
|
||||
operator const unsigned long long&() const { return millis; }
|
||||
};
|
||||
|
||||
inline unsigned long long jsTime() {
|
||||
boost::xtime xt;
|
||||
boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
|
||||
@@ -99,7 +99,21 @@ namespace mongo {
|
||||
return view;
|
||||
}
|
||||
|
||||
void MemoryMappedFile::flush(bool) {
|
||||
}
|
||||
void MemoryMappedFile::flush(bool sync) {
|
||||
uassert("Async flushing not supported on windows", sync);
|
||||
|
||||
if (!view) return;
|
||||
|
||||
bool success = FlushViewOfFile(view, 0); // 0 means whole mapping
|
||||
if (!success){
|
||||
int err = GetLastError();
|
||||
out() << "FlushViewOfFile failed " << err << endl;
|
||||
}
|
||||
|
||||
success = FlushFileBuffers(fd);
|
||||
if (!success){
|
||||
int err = GetLastError();
|
||||
out() << "FlushFileBuffers failed " << err << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,15 +20,24 @@
|
||||
#include "../db/concurrency.h"
|
||||
|
||||
namespace mongo {
|
||||
void exitCleanly( int code );
|
||||
|
||||
/* Operation sequence #. A combination of current second plus an ordinal value.
|
||||
*/
|
||||
struct ClockSkewException : public DBException {
|
||||
virtual const char* what() const throw() { return "clock skew exception"; }
|
||||
virtual int getCode(){ return 20001; }
|
||||
};
|
||||
|
||||
#pragma pack(4)
|
||||
class OpTime {
|
||||
unsigned i;
|
||||
unsigned secs;
|
||||
static OpTime last;
|
||||
public:
|
||||
static void setLast(const Date_t &date) {
|
||||
last = OpTime(date);
|
||||
}
|
||||
unsigned getSecs() const {
|
||||
return secs;
|
||||
}
|
||||
@@ -46,6 +55,20 @@ namespace mongo {
|
||||
static OpTime now() {
|
||||
unsigned t = (unsigned) time(0);
|
||||
// DEV assertInWriteLock();
|
||||
if ( t < last.secs ){
|
||||
bool toLog = false;
|
||||
ONCE toLog = true;
|
||||
RARELY toLog = true;
|
||||
if ( last.i & 0x80000000 )
|
||||
toLog = true;
|
||||
if ( toLog )
|
||||
log() << "clock skew detected prev: " << last.secs << " now: " << t << " trying to handle..." << endl;
|
||||
if ( last.i & 0x80000000 ) {
|
||||
log() << "ERROR Large clock skew detected, shutting down" << endl;
|
||||
throw ClockSkewException();
|
||||
}
|
||||
t = last.secs;
|
||||
}
|
||||
if ( last.secs == t ) {
|
||||
last.i++;
|
||||
return last;
|
||||
|
||||
Reference in New Issue
Block a user