summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDwight <dmerriman@gmail.com>2008-04-25 17:24:27 -0400
committerDwight <dmerriman@gmail.com>2008-04-25 17:24:27 -0400
commit8210548d7f4ca320def5567eed98aacec254bfad (patch)
tree36d2600c5d465b3e6b9329bb5a35e316e3a4aec8
parenteb204a454cfc4c9ae427b48cfd01fe2a4921a59e (diff)
downloadmongo-8210548d7f4ca320def5567eed98aacec254bfad.tar.gz
dbproblem.log file
-rw-r--r--db/btree.cpp1
-rw-r--r--db/db.cpp61
-rw-r--r--db/namespace.h2
-rw-r--r--db/pdfile.cpp15
-rw-r--r--db/pdfile.h5
-rw-r--r--db/query.cpp2
-rw-r--r--stdafx.cpp3
-rw-r--r--stdafx.h11
-rw-r--r--util/sock.cpp1
9 files changed, 84 insertions, 17 deletions
diff --git a/db/btree.cpp b/db/btree.cpp
index 0f424431fbe..7b3d4b4d1e2 100644
--- a/db/btree.cpp
+++ b/db/btree.cpp
@@ -471,6 +471,7 @@ void BtreeBucket::insertHere(DiskLoc thisLoc, const char *ns, int keypos,
break;
mid--;
if( mid < 3 ) {
+ problem() << "Assertion failure - mid<3: duplicate key bug not fixed yet" << endl;
cout << "Assertion failure - mid<3: duplicate key bug not fixed yet" << endl;
cout << " ns:" << ns << endl;
cout << " key:" << mn.key.toString() << endl;
diff --git a/db/db.cpp b/db/db.cpp
index 3d693a2cbdf..58aa29dfd7b 100644
--- a/db/db.cpp
+++ b/db/db.cpp
@@ -114,6 +114,7 @@ void receivedKillCursors(Message& m) {
int n = *x++;
assert( n >= 1 );
if( n > 2000 ) {
+ problem() << "Assertion failure, receivedKillCursors, n=" << n << endl;
cout << "Assertion failure, receivedKillCursors, n=" << n << endl;
assert( n < 30000 );
}
@@ -167,6 +168,7 @@ void receivedQuery(AbstractMessagingPort& dbMsgPort, Message& m, stringstream& s
}
catch( AssertionException ) {
ss << " exception ";
+ problem() << " Caught Assertion in runQuery " << ns << endl;
cout << " Caught Assertion in runQuery, continuing" << endl;
cout << " ntoskip:" << ntoskip << " ntoreturn:" << ntoreturn << endl;
cout << " ns:" << ns << endl;
@@ -269,7 +271,8 @@ public:
};
void listen(int port) {
- cout << "db version: 106 apr2008 group" << endl;
+ problem() << "db version: 107 apr2008 group" << endl;
+ cout << "db version: 107 apr2008 group" << endl;
pdfileInit();
testTheDb();
cout << curTimeMillis() % 10000 << " waiting for connections on port " << port << " ...\n" << endl;
@@ -347,6 +350,7 @@ void jniCallback(Message& m, Message& out)
receivedKillCursors(m);
}
catch( AssertionException ) {
+ problem() << "Caught Assertion in kill cursors, continuing" << endl;
cout << "Caught Assertion in kill cursors, continuing" << endl;
ss << " exception ";
}
@@ -372,6 +376,7 @@ void jniCallback(Message& m, Message& out)
}
catch( AssertionException ) {
+ problem() << "Caught AssertionException in jniCall()" << endl;
cout << "Caught AssertionException in jniCall()" << endl;
}
@@ -432,6 +437,7 @@ void connThread()
cout << curTimeMillis() % 10000 << " end msg" << endl;
dbMsgPort.shutdown();
sleepmillis(500);
+ problem() << "exiting end msg" << endl;
exit(EXIT_SUCCESS);
}
}
@@ -447,6 +453,7 @@ void connThread()
receivedInsert(m, ss);
}
catch( AssertionException ) {
+ problem() << "Caught Assertion insert, continuing" << endl;
cout << "Caught Assertion, continuing" << endl;
ss << " exception ";
}
@@ -457,7 +464,8 @@ void connThread()
receivedUpdate(m, ss);
}
catch( AssertionException ) {
- cout << "Caught Assertion, continuing" << endl;
+ problem() << "Caught Assertion update, continuing" << endl;
+ cout << "Caught Assertion update, continuing" << endl;
ss << " exception ";
}
}
@@ -467,7 +475,8 @@ void connThread()
receivedDelete(m);
}
catch( AssertionException ) {
- cout << "Caught Assertion, continuing" << endl;
+ problem() << "Caught Assertion receviedDelete, continuing" << endl;
+ cout << "Caught Assertion receviedDelete, continuing" << endl;
ss << " exception ";
}
}
@@ -484,6 +493,7 @@ void connThread()
}
catch( AssertionException ) {
cout << "Caught Assertion in kill cursors, continuing" << endl;
+ problem() << "Caught Assertion in kill cursors, continuing" << endl;
ss << " exception ";
}
}
@@ -510,6 +520,7 @@ void connThread()
}
catch( AssertionException ) {
cout << "Caught AssertionException, terminating" << endl;
+ problem() << "Caught AssertionException, terminating" << endl;
exit(-7);
}
}
@@ -556,12 +567,47 @@ void msg(const char *m, int extras = 0) {
msg(m, "127.0.0.1", DBPort, extras);
}
+#if !defined(_WIN32)
+
+#include <signal.h>
+
+void pipeSigHandler( int signal ) {
+ psignal( signal, "Signal Received : ");
+}
+
+void segvhandler(int x) {
+ cout << "got SIGSEGV " << x << ", terminating :-(" << endl;
+ problem() << "got SIGSEGV " << x << ", terminating :-(" << endl;
+ exit(-9);
+}
+
+void mysighandler(int x) {
+ // [dm] not working. why?
+ cout << "got kill or ctrl c signal " << x << ", terminating" << endl;
+ problem() << "got kill or ctrl c signal " << x << ", terminating" << endl;
+ exit(0);
+}
+
+void setupSignals() {
+ cout << "SETUPSIGNALS " << signal(SIGINT, mysighandler) << endl;
+// assert( signal(SIGINT, mysighandler) != SIG_ERR );
+ assert( signal(SIGTERM, mysighandler) != SIG_ERR );
+ assert( signal(SIGQUIT, mysighandler) != SIG_ERR );
+ assert( signal(SIGSEGV, segvhandler) != SIG_ERR );
+}
+
+#else
+void setupSignals() {}
+#endif
void initAndListen(int listenPort, const char *dbPath) {
+ setupSignals();
+
dbpath = dbPath;
cout << "10Gen DB : starting : port = " << port << " dbpath = " << dbpath << endl;
+ problem() << "10Gen DB : starting : port = " << port << " dbpath = " << dbpath << endl;
JavaJS = new JavaJSImpl();
javajstest();
@@ -569,14 +615,13 @@ void initAndListen(int listenPort, const char *dbPath) {
listen(listenPort);
}
-void sigHandler( int signal ) {
- psignal( signal, "Signal Received : ");
-} /*handler*/
+ofstream problems("../log/dbproblems.log", ios_base::app | ios_base::out);
int main(int argc, char* argv[], char *envp[] )
{
- signal(SIGPIPE, sigHandler);
-
+#if !defined(_WIN32)
+ signal(SIGPIPE, pipeSigHandler);
+#endif
srand(curTimeMillis());
if( argc >= 2 ) {
diff --git a/db/namespace.h b/db/namespace.h
index 7ab03e2cd05..1d76695acb6 100644
--- a/db/namespace.h
+++ b/db/namespace.h
@@ -131,7 +131,7 @@ public:
const int LEN = 16 * 1024 * 1024;
void *p = f.map(path.c_str(), LEN);
if( p == 0 ) {
- cout << "couldn't open namespace.idx " << path.c_str() << endl;
+ problem() << "couldn't open namespace.idx " << path.c_str() << " terminating" << endl;
exit(-3);
}
ht = new HashTable<Namespace,NamespaceDetails>(p, LEN, "namespace index");
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index c1048833041..972407e4095 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -31,7 +31,11 @@ int callDepth = 0;
extern int otherTraceLevel;
-void sayDbContext() {
+void sayDbContext(const char *errmsg) {
+ if( errmsg ) {
+ cout << errmsg << '\n';
+ problem() << errmsg << endl;
+ }
cout << " client: " << (client ? client->name.c_str() : "null");
cout << " op:" << curOp << ' ' << callDepth << endl;
if( client )
@@ -105,8 +109,6 @@ DiskLoc NamespaceDetails::alloc(const char *ns, int lenToAlloc, DiskLoc& extentL
return loc;
}
-void sayDbContext();
-
/* returned item is out of the deleted list upon return */
DiskLoc NamespaceDetails::__alloc(int len) {
DiskLoc *prev;
@@ -121,7 +123,8 @@ DiskLoc NamespaceDetails::__alloc(int len) {
{
int a = cur.a();
if( a < -1 || a >= 100000 ) {
- cout << "Assertion failure - a() out of range in _alloc() " << a << endl;
+ problem() << "Assertion failure - a() out of range in _alloc() " << a << endl;
+ cout << "Assertion failure - a() out of range in _alloc() " << a << '\n';
sayDbContext();
if( cur == *prev )
prev->Null();
@@ -570,6 +573,7 @@ void _unindexRecord(const char *ns, IndexDetails& id, JSObj& obj, const DiskLoc&
}
if( !ok ) {
+ problem() << "Assertion failure: _unindex failed " << ns << endl;
cout << "Assertion failure: _unindex failed" << '\n';
cout << " obj:" << obj.toString() << '\n';
cout << " key:" << j.toString() << '\n';
@@ -695,6 +699,7 @@ void DataFileMgr::update(
catch(AssertionException) {
ss << " exception update unindex ";
cout << " caught assertion update unindex " << idxns.c_str() << '\n';
+ problem() << " caught assertion update unindex " << idxns.c_str() << endl;
}
}
vector<JSObj*> added;
@@ -709,6 +714,7 @@ void DataFileMgr::update(
catch(AssertionException) {
ss << " exception update index ";
cout << " caught assertion update index " << idxns.c_str() << '\n';
+ problem() << " caught assertion update index " << idxns.c_str() << endl;
}
}
if( client->profile )
@@ -747,6 +753,7 @@ void _indexRecord(IndexDetails& idx, JSObj& obj, DiskLoc newRecordLoc) {
}
catch(AssertionException) {
cout << " caught assertion _indexRecord " << idx.indexNamespace() << '\n';
+ problem() << " caught assertion _indexRecord " << idx.indexNamespace() << endl;
}
}
}
diff --git a/db/pdfile.h b/db/pdfile.h
index ef0b015745e..9f03a5b341d 100644
--- a/db/pdfile.h
+++ b/db/pdfile.h
@@ -277,14 +277,13 @@ public:
inline Record* PhysicalDataFile::recordAt(DiskLoc dl) { return header->getRecord(dl); }
-void sayDbContext();
+void sayDbContext(const char *msg = 0);
inline DiskLoc Record::getNext(const DiskLoc& myLoc) {
if( nextOfs != DiskLoc::NullOfs ) {
/* defensive */
if( nextOfs >= 0 && nextOfs < 10 ) {
- cout << "Assertion failure - Record::getNext() referencing a deleted record?" << endl;
- sayDbContext();
+ sayDbContext("Assertion failure - Record::getNext() referencing a deleted record?");
return DiskLoc();
}
diff --git a/db/query.cpp b/db/query.cpp
index 21739dfa157..742d25e0938 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -464,6 +464,8 @@ inline bool runCommands(const char *ns, JSObj& jsobj, stringstream& ss, BufBuild
Element e;
e = jsobj.firstElement();
+ assert(false);
+
if( e.eoo() ) goto done;
if( e.type() == Code ) {
valid = true;
diff --git a/stdafx.cpp b/stdafx.cpp
index 3a5eba374c2..0d4d4346506 100644
--- a/stdafx.cpp
+++ b/stdafx.cpp
@@ -18,9 +18,10 @@ struct MyAsserts {
#undef yassert
#include "assert.h"
-void sayDbContext();
+void sayDbContext(const char *p = 0);
void wasserted(const char *msg, const char *file, unsigned line) {
+ problem() << "Assertion failure " << msg << ' ' << file << ' ' << line << endl;
cout << "Assertion failure " << msg << endl;
cout << ' ' << file << ' ' << line << endl;
sayDbContext();
diff --git a/stdafx.h b/stdafx.h
index 567f37be5b5..e9b68dbf200 100644
--- a/stdafx.h
+++ b/stdafx.h
@@ -47,6 +47,7 @@ typedef char _TCHAR;
#include <fstream>
using namespace std;
+#include "time.h"
#include <map>
#include <string>
#include <vector>
@@ -86,3 +87,13 @@ typedef struct _OWS {
char string[400];
} *OWS;
+extern ofstream problems;
+
+// not threadsafe
+inline ofstream& problem() {
+ time_t t;
+ time(&t);
+ string now(ctime(&t),0,20);
+ problems << now;
+ return problems;
+}
diff --git a/util/sock.cpp b/util/sock.cpp
index 6d25536bfb3..7b0c20e7ff5 100644
--- a/util/sock.cpp
+++ b/util/sock.cpp
@@ -36,6 +36,7 @@ struct SockStartupTests {
WSADATA d;
if( WSAStartup(MAKEWORD(2,2), &d) != 0 ) {
cout << "ERROR: wsastartup failed " << errno << endl;
+ problem() << "ERROR: wsastartup failed " << errno << endl;
exit(1);
}
#endif