Permalink
Browse files

Merge branch 'master' of github.com:mongodb/mongo

  • Loading branch information...
2 parents 21f963c + ccd75a2 commit 202000055fe3927a91adca190e7f4fc8d8e7a88f @erh erh committed Apr 25, 2012
View
@@ -625,7 +625,7 @@ elif "win32" == os.sys.platform:
else:
env.Append( LINKFLAGS=" /NODEFAULTLIB:MSVCPRT /NODEFAULTLIB:MSVCRT " )
- winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib"
+ winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib DbgHelp.lib"
if force64:
View
@@ -105,3 +105,5 @@ tzz = db.capped6;
for( var i = 0; i < 10; ++i ) {
doTest();
}
+
+//tzz.drop();
View
@@ -104,3 +104,5 @@ print("pass " + pass++);
t.drop();
db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000 ] } );
testTruncate();
+
+t.drop();
View
@@ -7,5 +7,5 @@ for ( var i=0; i<50; i++ ) { // enough iterations to break 32 bit.
assert( t.count() == 1 );
t.drop();
}
+t.drop();
-db.dropDatabase();
View
@@ -6,8 +6,7 @@
t = db.indexb;
-db.dropDatabase();
-
+t.drop();
t.ensureIndex({a:1},true);
t.insert({a:1});
View
@@ -20,6 +20,9 @@ def add_exe( v ):
# ------ SOURCE FILE SETUP -----------
+env.StaticLibrary('log', [ 'util/assert_util.cpp',
+ 'util/log.cpp', ])
+
commonFiles = [ "pch.cpp",
"buildinfo.cpp",
"db/jsobj.cpp",
@@ -37,9 +40,7 @@ commonFiles = [ "pch.cpp",
"util/timer.cpp",
"util/util.cpp",
"util/file_allocator.cpp",
- "util/assert_util.cpp",
"util/trace.cpp",
- "util/log.cpp",
"util/ramlog.cpp",
"util/progress_meter.cpp",
"util/md5main.cpp",
@@ -73,7 +74,8 @@ commonFiles = [ "pch.cpp",
"s/shardconnection.cpp"]
env.StaticLibrary('mongocommon', commonFiles,
- LIBDEPS=['stacktrace',
+ LIBDEPS=['log',
+ 'stacktrace',
'$BUILD_DIR/third_party/pcrecpp',
'$BUILD_DIR/third_party/murmurhash3/murmurhash3',
'$BUILD_DIR/third_party/mongo_boost'],)
@@ -40,7 +40,7 @@ namespace mongo {
dbexit( code );
}
- void dbexit( ExitCode returnCode, const char *whyMsg , bool tryToGetLock ) {
+ void dbexit( ExitCode returnCode, const char *whyMsg ) {
{
mongo::mutex::scoped_lock lk( shell_utils::mongoProgramOutputMutex );
dbexitCalled = true;
@@ -28,6 +28,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/json.h"
#include "mongo/util/background.h"
+#include "mongo/util/scopeguard.h"
#include "mongo/util/timer.h"
namespace mongo {
@@ -323,8 +324,13 @@ namespace mongo {
if ( !authenticatedConn->runCommand( "admin", BSON( "replSetGetStatus" << 1 ), status )) {
LOG(1) << "dbclient_rs replSetGetStatus failed" << endl;
+ authenticatedConn.done(); // connection worked properly, but we got an error from server
return;
}
+
+ // Make sure we return when finished
+ authenticatedConn.done();
+
if( !status.hasField("members") ) {
log() << "dbclient_rs error expected members field in replSetGetStatus result" << endl;
return;
@@ -13,7 +13,7 @@
namespace mongo {
class WrapperForRWLock;
- struct LockState;
+ class LockState;
class Lock : boost::noncopyable {
public:
@@ -143,14 +143,6 @@ namespace mongo {
bool got() const { return _got; }
};
- struct readlocktryassert : public readlocktry {
- readlocktryassert(int tryms) :
- readlocktry(tryms) {
- uassert(13142, "timeout getting readlock", got());
- }
- };
-
-
/** a mutex, but reported in curop() - thus a "high level" (HL) one
some overhead so we don't use this for everything. the externalobjsort mutex
uses this, as it can be held for eons. implementation still needed. */
View
@@ -48,6 +48,7 @@
#if defined(_WIN32)
# include "../util/ntservice.h"
+# include <DbgHelp.h>
#else
# include <sys/file.h>
#endif
@@ -1130,7 +1131,7 @@ namespace mongo {
rawOut( oss.str() );
// Don't go through normal shutdown procedure. It may make things worse.
- ::exit(EXIT_ABRUPT);
+ ::_exit(EXIT_ABRUPT);
}
@@ -1171,7 +1172,7 @@ namespace mongo {
void my_new_handler() {
rawOut( "out of memory, printing stack and exiting:" );
printStackTrace();
- ::exit(EXIT_ABRUPT);
+ ::_exit(EXIT_ABRUPT);
}
void setupSignals_ignoreHelper( int signal ) {}
@@ -1253,6 +1254,48 @@ namespace mongo {
LPTOP_LEVEL_EXCEPTION_FILTER filtLast = 0;
+ /* create a process dump.
+ To use, load up windbg. Set your symbol and source path.
+ Open the crash dump file. To see the crashing context, use .ecxr
+ */
+ void doMinidump(struct _EXCEPTION_POINTERS* exceptionInfo) {
+ LPCWSTR dumpFilename = L"mongo.dmp";
+ HANDLE hFile = CreateFileW(dumpFilename,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+ if ( INVALID_HANDLE_VALUE == hFile ) {
+ DWORD lasterr = GetLastError();
+ log() << "failed to open minidump file " << dumpFilename << " : "
+ << errnoWithDescription( lasterr ) << endl;
+ return;
+ }
+
+ MINIDUMP_EXCEPTION_INFORMATION aMiniDumpInfo;
+ aMiniDumpInfo.ThreadId = GetCurrentThreadId();
+ aMiniDumpInfo.ExceptionPointers = exceptionInfo;
+ aMiniDumpInfo.ClientPointers = TRUE;
+
+ log() << "writing minidump dignostic file " << dumpFilename << endl;
+ BOOL bstatus = MiniDumpWriteDump(GetCurrentProcess(),
+ GetCurrentProcessId(),
+ hFile,
+ MiniDumpNormal,
+ &aMiniDumpInfo,
+ NULL,
+ NULL);
+ if ( FALSE == bstatus ) {
+ DWORD lasterr = GetLastError();
+ log() << "failed to create minidump : "
+ << errnoWithDescription( lasterr ) << endl;
+ }
+
+ CloseHandle(hFile);
+ }
+
LONG WINAPI exceptionFilter( struct _EXCEPTION_POINTERS *excPointers ) {
char exceptionString[128];
sprintf_s( exceptionString, sizeof( exceptionString ),
@@ -1285,6 +1328,8 @@ namespace mongo {
log() << "*** access violation was a " << acTypeString << addressString << endl;
}
+ doMinidump(excPointers);
+
// In release builds, let dbexit() try to shut down cleanly
#if !defined(_DEBUG)
dbexit( EXIT_UNCAUGHT, "unhandled exception" );
View
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@@ -1218,6 +1218,7 @@
<ClCompile Include="..\util\stringutils.cpp" />
<ClCompile Include="..\util\systeminfo_win32.cpp" />
<ClCompile Include="..\util\text.cpp" />
+ <ClCompile Include="..\util\timer.cpp" />
<ClCompile Include="..\util\trace.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
@@ -1332,6 +1333,8 @@
<ClInclude Include="..\util\progress_meter.h" />
<ClInclude Include="..\util\concurrency\remap_lock.h" />
<ClInclude Include="..\util\stacktrace.h" />
+ <ClInclude Include="..\util\timer-win32-inl.h" />
+ <ClInclude Include="..\util\timer.h" />
<ClInclude Include="explain.h" />
<ClInclude Include="index_insertion_continuation.h" />
<ClInclude Include="lockstat.h" />
@@ -472,6 +472,7 @@
<ClCompile Include="commands\fsync.cpp">
<Filter>db\commands</Filter>
</ClCompile>
+ <ClCompile Include="..\util\timer.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\client\distlock.h" />
@@ -770,6 +771,8 @@
<Filter>db</Filter>
</ClInclude>
<ClInclude Include="..\util\stacktrace.h" />
+ <ClInclude Include="..\util\timer.h" />
+ <ClInclude Include="..\util\timer-win32-inl.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\jstests\dur\dur1.js" />
@@ -315,6 +315,8 @@ namespace mongo {
// regardless of whether they caught up, we'll shut down
}
+ writelocktry wlt( 2 * 60 * 1000 );
+ uassert( 13455 , "dbexit timed out getting lock" , wlt.got() );
return shutdownHelper();
}
@@ -1804,6 +1806,7 @@ namespace mongo {
virtual bool slaveOk() const { return false; }
virtual LockType locktype() const { return WRITE; }
virtual bool requiresAuth() { return true; }
+ virtual bool logTheOp() { return true; }
virtual bool run(const string& dbname , BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool) {
string coll = cmdObj[ "emptycapped" ].valuestrsafe();
uassert( 13428, "emptycapped must specify a collection", !coll.empty() );
@@ -384,7 +384,7 @@ namespace mongo {
log() << "terminating, shutdown command received" << endl;
- dbexit( EXIT_CLEAN , "shutdown called" , true ); // this never returns
+ dbexit( EXIT_CLEAN , "shutdown called" ); // this never returns
verify(0);
return true;
}
View
@@ -251,7 +251,7 @@ namespace mongo {
}
static int in_f;
- void f() {
+ void f_commitEarlyInRunExclusively() {
dassert( in_f == 0 );
in_f++;
try {
@@ -314,7 +314,7 @@ namespace mongo {
}
else {
log(1) << "commitIfNeeded calling runExclusively " << force << endl;
- runExclusively(f);
+ runExclusively(f_commitEarlyInRunExclusively);
}
}
else {
@@ -626,26 +626,26 @@ namespace mongo {
if( !commitJob.hasWritten() ) {
// getlasterror request could have came after the data was already committed
commitJob.committingNotifyCommitted();
- return;
}
+ else {
+ JSectHeader h;
+ PREPLOGBUFFER(h,ab);
- JSectHeader h;
- PREPLOGBUFFER(h,ab);
-
- // todo : write to the journal outside locks, as this write can be slow.
- // however, be careful then about remapprivateview as that cannot be done
- // if new writes are then pending in the private maps.
- WRITETOJOURNAL(h, ab);
+ // todo : write to the journal outside locks, as this write can be slow.
+ // however, be careful then about remapprivateview as that cannot be done
+ // if new writes are then pending in the private maps.
+ WRITETOJOURNAL(h, ab);
- // data is now in the journal, which is sufficient for acknowledging getLastError.
- // (ok to crash after that)
- commitJob.committingNotifyCommitted();
+ // data is now in the journal, which is sufficient for acknowledging getLastError.
+ // (ok to crash after that)
+ commitJob.committingNotifyCommitted();
- WRITETODATAFILES(h, ab);
- debugValidateAllMapsMatch();
+ WRITETODATAFILES(h, ab);
+ debugValidateAllMapsMatch();
- commitJob.committingReset();
- ab.reset();
+ commitJob.committingReset();
+ ab.reset();
+ }
// REMAPPRIVATEVIEW
//
@@ -790,6 +790,8 @@ namespace mongo {
break;
sleepmillis(oneThird);
}
+
+ //DEV log() << "privateMapBytes=" << privateMapBytes << endl;
durThreadGroupCommit();
}
View
@@ -413,7 +413,7 @@ namespace mongo {
}
else if ( ! c.getAuthenticationInfo()->isAuthorized(
nsToDatabase( m.singleData()->_data + 4 ) ) ) {
- uassert_nothrow("unauthorized");
+ setLastError(0, "unauthorized");
}
else if ( op == dbInsert ) {
receivedInsert(m, currentOp);
@@ -999,13 +999,7 @@ namespace mongo {
}
/* not using log() herein in case we are already locked */
- NOINLINE_DECL void dbexit( ExitCode rc, const char *why, bool tryToGetLock ) {
-
- auto_ptr<writelocktry> wlt;
- if ( tryToGetLock ) {
- wlt.reset( new writelocktry( 2 * 60 * 1000 ) );
- uassert( 13455 , "dbexit timed out getting lock" , wlt->got() );
- }
+ NOINLINE_DECL void dbexit( ExitCode rc, const char *why ) {
Client * c = currentClient.get();
{
@@ -28,7 +28,7 @@ namespace mongo {
LastErrorHolder lastError;
bool isShell = false;
- void raiseError(int code , const char *msg) {
+ void setLastError(int code , const char *msg) {
LastError *le = lastError.get();
if ( le == 0 ) {
/* might be intentional (non-user thread) */
View
@@ -17,7 +17,7 @@
#pragma once
-#include "../bson/oid.h"
+#include "mongo/bson/oid.h"
namespace mongo {
class BSONObjBuilder;
@@ -147,6 +147,6 @@ namespace mongo {
};
} lastError;
- void raiseError(int code , const char *msg);
+ void setLastError(int code , const char *msg);
} // namespace mongo
Oops, something went wrong.

0 comments on commit 2020000

Please sign in to comment.