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