mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of ssh://git.10gen.com/data/gitroot/p
This commit is contained in:
commit
8d00ee0321
@ -273,6 +273,7 @@ extern NamespaceIndexMgr namespaceIndexMgr;
|
||||
*/
|
||||
|
||||
// "client.a.b.c" -> "client"
|
||||
const int MaxClientLen = 256;
|
||||
inline void nsToClient(const char *ns, char *client) {
|
||||
const char *p = ns;
|
||||
char *q = client;
|
||||
@ -285,7 +286,10 @@ inline void nsToClient(const char *ns, char *client) {
|
||||
*q++ = *p++;
|
||||
}
|
||||
*q = 0;
|
||||
assert(q-client<256);
|
||||
if(q-client>=MaxClientLen) {
|
||||
problem() << "nsToClient: ns too long. terminating, buf overrun condition" << endl;
|
||||
dbexit(60);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -47,6 +47,9 @@ int callDepth = 0;
|
||||
|
||||
extern int otherTraceLevel;
|
||||
|
||||
/* this is a good place to set a breakpoint when debugging, as lots of warning things
|
||||
(assert, wassert) call it.
|
||||
*/
|
||||
void sayDbContext(const char *errmsg) {
|
||||
if( errmsg ) {
|
||||
problem() << errmsg << endl;
|
||||
|
29
db/repl.cpp
29
db/repl.cpp
@ -69,13 +69,14 @@ int test2() {
|
||||
/* --------------------------------------------------------------*/
|
||||
|
||||
Source::Source(JSObj o) {
|
||||
only = o.getStringField("only");
|
||||
hostName = o.getStringField("host");
|
||||
sourceName = o.getStringField("source");
|
||||
uassert( !hostName.empty() );
|
||||
uassert( !sourceName.empty() );
|
||||
uassert( "'host' field not set in sources collection object", !hostName.empty() );
|
||||
uassert( "'source' field not set in sources collection object", !sourceName.empty() );
|
||||
Element e = o.getField("syncedTo");
|
||||
if( !e.eoo() ) {
|
||||
uassert( e.type() == Date );
|
||||
uassert( "bad sources 'syncedTo' field value", e.type() == Date );
|
||||
OpTime tmp( e.date() );
|
||||
syncedTo = tmp;
|
||||
//syncedTo.asDate() = e.date();
|
||||
@ -98,6 +99,8 @@ JSObj Source::jsobj() {
|
||||
JSObjBuilder b;
|
||||
b.append("host", hostName);
|
||||
b.append("source", sourceName);
|
||||
if( !only.empty() )
|
||||
b.append("only", only);
|
||||
b.appendDate("syncedTo", syncedTo.asDate());
|
||||
|
||||
JSObjBuilder dbs_builder;
|
||||
@ -198,11 +201,17 @@ bool Source::resync(string db) {
|
||||
}
|
||||
|
||||
/* { ts: ..., op: <optype>, ns: ..., o: <obj> , o2: <extraobj>, b: <boolflag> }
|
||||
You must lock dbMutex before calling.
|
||||
*/
|
||||
void Source::applyOperation(JSObj& op) {
|
||||
stringstream ss;
|
||||
void Source::applyOperation(JSObj& op) {
|
||||
char clientName[MaxClientLen];
|
||||
const char *ns = op.getStringField("ns");
|
||||
nsToClient(ns, clientName);
|
||||
|
||||
if( !only.empty() && only != clientName )
|
||||
return;
|
||||
|
||||
dblock lk;
|
||||
|
||||
setClientTempNs(ns);
|
||||
|
||||
if( client->justCreated || /* datafiles were missing. so we need everything, no matter what sources object says */
|
||||
@ -212,6 +221,7 @@ void Source::applyOperation(JSObj& op) {
|
||||
client->justCreated = false;
|
||||
}
|
||||
|
||||
stringstream ss;
|
||||
const char *opType = op.getStringField("op");
|
||||
JSObj o = op.getObjectField("o");
|
||||
if( *opType == 'i' ) {
|
||||
@ -303,7 +313,6 @@ void Source::pullOpLog() {
|
||||
log() << "pull: initial run\n";
|
||||
}
|
||||
{
|
||||
dblock lk;
|
||||
applyOperation(op);
|
||||
n++;
|
||||
}
|
||||
@ -320,11 +329,11 @@ void Source::pullOpLog() {
|
||||
|
||||
// apply operations
|
||||
{
|
||||
dblock lk;
|
||||
while( 1 ) {
|
||||
if( !c->more() ) {
|
||||
log() << "pull: applied " << n << " operations" << endl;
|
||||
syncedTo = t;
|
||||
dblock lk;
|
||||
save(); // note how far we are synced up to now
|
||||
break;
|
||||
}
|
||||
@ -337,7 +346,7 @@ void Source::pullOpLog() {
|
||||
t = tmp;
|
||||
if( !( last < t ) ) {
|
||||
problem() << "sync error: last " << last.toString() << " >= t " << t.toString() << endl;
|
||||
uassert(false);
|
||||
uassert("bad 'ts' value in sources", false);
|
||||
}
|
||||
|
||||
applyOperation(op);
|
||||
@ -489,7 +498,7 @@ void replMain() {
|
||||
int debug_stop_repl = 0;
|
||||
|
||||
void replSlaveThread() {
|
||||
sleepsecs(3);
|
||||
sleepsecs(30);
|
||||
while( 1 ) {
|
||||
try {
|
||||
replMain();
|
||||
|
@ -95,6 +95,7 @@ class Source {
|
||||
public:
|
||||
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.
|
||||
|
||||
/* the last time point we have already synced up to. */
|
||||
OpTime syncedTo;
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
JSObj k = order.getKeyFromObject(o);
|
||||
if( (int) best.size() < limit ) {
|
||||
approxSize += k.objsize();
|
||||
uassert( approxSize < 1 * 1024 * 1024 );
|
||||
uassert( "too much key data for sort() with no index", approxSize < 1 * 1024 * 1024 );
|
||||
_add(k, o);
|
||||
return;
|
||||
}
|
||||
@ -111,7 +111,7 @@ public:
|
||||
nFilled++;
|
||||
if( nFilled >= limit )
|
||||
goto done;
|
||||
uassert( b.len() < 4000000 ); // appserver limit
|
||||
uassert( "too much data for sort() with no index", b.len() < 4000000 ); // appserver limit
|
||||
}
|
||||
}
|
||||
done:
|
||||
|
@ -46,8 +46,8 @@ void asserted(const char *msg, const char *file, unsigned line) {
|
||||
throw AssertionException();
|
||||
}
|
||||
|
||||
void uasserted(const char *msg, const char *file, unsigned line) {
|
||||
problem() << "User Assertion failure " << msg << ' ' << file << ' ' << line << endl;
|
||||
void uasserted(const char *msg) {
|
||||
problem() << "User Assertion " << msg << endl;
|
||||
throw AssertionException();
|
||||
}
|
||||
|
||||
|
5
stdafx.h
5
stdafx.h
@ -58,7 +58,7 @@ public:
|
||||
|
||||
void asserted(const char *msg, const char *file, unsigned line);
|
||||
void wasserted(const char *msg, const char *file, unsigned line);
|
||||
void uasserted(const char *msg, const char *file, unsigned line);
|
||||
void uasserted(const char *msg);
|
||||
void msgasserted(const char *msg);
|
||||
|
||||
#ifdef assert
|
||||
@ -68,7 +68,8 @@ void msgasserted(const char *msg);
|
||||
#define assert(_Expression) (void)( (!!(_Expression)) || (asserted(#_Expression, __FILE__, __LINE__), 0) )
|
||||
|
||||
/* "user assert". if asserts, user did something wrong, not our code */
|
||||
#define uassert(_Expression) (void)( (!!(_Expression)) || (uasserted(#_Expression, __FILE__, __LINE__), 0) )
|
||||
//#define uassert(_Expression) (void)( (!!(_Expression)) || (uasserted(#_Expression, __FILE__, __LINE__), 0) )
|
||||
#define uassert(msg,_Expression) (void)( (!!(_Expression)) || (uasserted(msg), 0) )
|
||||
|
||||
#define xassert(_Expression) (void)( (!!(_Expression)) || (asserted(#_Expression, __FILE__, __LINE__), 0) )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user