Compare commits

...

81 Commits

Author SHA1 Message Date
Eliot Horowitz
5cf582d3d9 Merge branch 'v1.2' of github.com:mongodb/mongo into v1.2 2010-03-01 20:36:12 -05:00
Eliot Horowitz
4a7c73f5e2 BUMP 1.2.4 2010-03-01 20:35:52 -05:00
Richard Kreuter
ee388151a7 Backport some changes to debian/ from devel branch HEAD. 2010-03-01 17:59:58 -05:00
Eliot Horowitz
8e3d106320 strip comments from javascript 2010-02-26 18:06:02 -05:00
Eliot Horowitz
76d4703561 fix ugly quit() message 2010-02-26 18:00:08 -05:00
Aaron
1d82d20390 CS-6 update unit test 2010-02-25 21:21:00 -08:00
Aaron
de365ac8eb CS-6 fix for 'only' mode 2010-02-25 20:59:44 -08:00
Aaron
a05b907fc4 SERVER-500 clean up processes in test 2010-02-24 17:12:52 -08:00
Eliot Horowitz
fcb6a16b48 SERVER-500 - use ports < 32867 and no http interface for sharding tests 2010-02-23 22:28:57 -08:00
Aaron
074553298d SERVER-500 use lower port for scons mongod 2010-02-23 22:28:42 -08:00
Aaron
92b27770be SERVER-500 lower base port for e2e tests 2010-02-23 22:27:59 -08:00
Aaron
c62aa841a2 SERVER-500 try hardcoded ports 2010-02-23 22:27:26 -08:00
Eliot Horowitz
5ded448a90 post 1.2.3 2010-02-23 21:37:28 -05:00
Eliot Horowitz
d498124c60 BUMP 1.2.3 2010-02-23 17:29:40 -05:00
Mathias Stearn
8d182e1639 make smokeTool a noop on windows (v1.2) 2010-02-23 15:43:03 -05:00
Mathias Stearn
90f5b501f2 Do globing in SConstruct (1.2 branch) 2010-02-23 14:52:45 -05:00
Eliot Horowitz
67f8e66058 compile windows 2010-02-21 11:58:15 -05:00
Eliot Horowitz
3895bcd00b fix for solaris compile 2010-02-21 11:42:24 -05:00
Eliot Horowitz
8cd3f5b5d4 slightly stupid way to make memory on indexing not so bad for 1.2 SERVER-651 2010-02-21 10:40:34 -05:00
Eliot Horowitz
c75c00cfa8 better maxPasses again SERVER-649 2010-02-20 16:40:35 -05:00
Eliot Horowitz
bf7640dfa8 more tweaks for determining maxPasses SERVER-649 2010-02-20 16:40:27 -05:00
Eliot Horowitz
d95fa41f50 handle oplog case where mixed working set may require much oplog scanning SERVER-649
Conflicts:

	db/namespace.cpp
2010-02-20 16:40:19 -05:00
Eliot Horowitz
e987a94c7c better debugging for SERVER-650 2010-02-20 16:39:01 -05:00
Richard Kreuter
b790e13761 Merge branch 'v1.2' of github.com:mongodb/mongo into v1.2 2010-02-18 14:24:10 -05:00
Eliot Horowitz
b83c5efe35 don't use backtrace on freebsd SERVER-644 2010-02-17 14:57:30 -05:00
Eliot Horowitz
e07cbe6088 sequential option for mmap SERVER-607
Conflicts:

	db/extsort.cpp
2010-02-16 00:39:39 -05:00
Richard Kreuter
899328a8cf Backport hacks_ubuntu.py tweak for Debian. MINOR 2010-02-11 17:38:22 -05:00
Richard Kreuter
fc3d3acafc Run mongod as user mongodb on upstart systems in 1.2 branch. MINOR 2010-02-10 14:10:46 -05:00
Richard Kreuter
30c0576b8b Add a couple formerly-gitignored files under debian/. MINOR 2010-02-10 10:57:31 -05:00
Richard Kreuter
ba32baba1c Frob version numbers in debian/changelog to 1.2.2. MINOR 2010-02-10 10:40:38 -05:00
Richard Kreuter
a71dbfc15a Apply changes to debian/ to 1.2.x branch. MINOR 2010-02-10 10:37:02 -05:00
Aaron
a2bc5e3269 CS-10 prevent assertion by making sure btree builder enforces >= 1 key per bucket invariant 2010-02-08 20:48:50 -05:00
Eliot Horowitz
efb769e3b6 fix merge from master 2010-02-06 23:45:49 -05:00
Eliot Horowitz
ec1550c63d better btree assert 2010-02-06 14:46:28 -05:00
Eliot Horowitz
2dc3d5b577 fix _id lookup with no index SERVER-608 2010-02-06 10:49:42 -05:00
Eliot Horowitz
188436f8c9 assert checking for _Id lookup 2010-02-06 10:47:48 -05:00
Eliot Horowitz
48ba6d2991 --quiet surpresses sleep message 2010-02-05 10:53:51 -05:00
Eliot Horowitz
ba4cdb7b4c bb files 2010-02-05 09:45:33 -05:00
Mathias Stearn
38a924346d Make Archlinux use spidermonkey rather than xulrunner
(cherry picked from commit 4922004527)
2010-02-03 16:13:50 -05:00
Eliot Horowitz
be98c677cc diaglog obey --dbpath SERVER-601 2010-02-03 12:53:04 -05:00
Eliot Horowitz
bda359e9a1 dummy smokeAuth 2010-01-29 23:18:39 -05:00
Eliot Horowitz
a6d7b21ccd after 1.2.2 2010-01-27 10:00:04 -05:00
Eliot Horowitz
8a4fb8b1c7 BUMP 1.2.2 2010-01-26 12:56:05 -05:00
Eliot Horowitz
a6d37a6d3e fix: m/r emit error gets spidermonkey into bad state SERVER-570 2010-01-26 10:43:30 -05:00
Eliot Horowitz
41232b6557 better debugging for invalid objects
Conflicts:

	db/jsobj.h
	dbtests/jsobjtests.cpp
2010-01-26 10:06:33 -05:00
dwight
a4f9e4bc12 don't assert in rawout 2010-01-25 16:14:10 -05:00
Eliot Horowitz
6a324b4a98 $set doesn't convert from int to other types SERVER-555 2010-01-20 09:53:48 -05:00
Dwight
04aabf6194 elim warning on windows
(cherry picked from commit 95ba1b843e)
2010-01-19 22:06:41 -05:00
Mathias Stearn
5a2da6b86f Better VirtualMemorySize on windows
(cherry picked from commit 42ec730af2)
2010-01-19 22:04:25 -05:00
Mathias Stearn
c461be6e17 fix uninitialized length for MemoryMapFile on windows.
(cherry picked from commit 32acd37d75)
2010-01-19 22:04:17 -05:00
Eliot Horowitz
7907050da3 don't display client shutdown on --upgrade or repair SERVER-554 2010-01-19 16:43:37 -05:00
Eliot Horowitz
2ce38e3376 use boost sleep on sunos SERVER-548 2010-01-15 09:31:05 -05:00
Eliot Horowitz
5b36ef5cfa use nanosleep on *nix rather than boost, trying to fix os x issue SERVER-539
Conflicts:

	dbtests/basictests.cpp
2010-01-14 16:48:41 -05:00
Eliot Horowitz
56b803b9f2 try to fix win64 memory take 4 SERVER-528 2010-01-11 06:54:39 -05:00
Eliot Horowitz
48c7684617 try to fix win64 memory take 3 SERVER-528 2010-01-11 06:44:32 -05:00
Eliot Horowitz
17a2a93bb5 try to fix win64 memory take 2 SERVER-528 2010-01-11 06:39:01 -05:00
Eliot Horowitz
2b59b7f0c5 try to fix win64 memory SERVER-528 2010-01-11 06:29:40 -05:00
Eliot Horowitz
dc1ebc586e make mem info work on win32 SERVER-528
Conflicts:

	jstests/dbadmin.js
2010-01-11 06:17:06 -05:00
Eliot Horowitz
1c4843d497 don't make running out of threads crash db SERVER-527 2010-01-10 02:21:48 +01:00
Eliot Horowitz
054917e5c4 help people trying to access http on driver port 2010-01-02 21:42:11 -05:00
Eliot Horowitz
209968640d after 1.2.1 2009-12-30 14:44:38 -05:00
Eliot Horowitz
45992de574 BUMP 1.2.1 2009-12-30 13:01:40 -05:00
Mathias Stearn
961d3ab8b2 Backport fix to 1.2 branch. SERVER-410. 2009-12-29 17:13:03 -05:00
Eliot Horowitz
f8f12e8d13 beter error handling in m/r 2009-12-29 14:26:12 -05:00
Eliot Horowitz
720eecdc01 fix compile 2009-12-22 12:58:41 -05:00
Eliot Horowitz
5dc18ddb3b better repl debugging 2009-12-22 11:07:36 -05:00
Eliot Horowitz
9280f63a83 fix compile on gcc 4.4.2 2009-12-20 07:17:54 -05:00
Eliot Horowitz
007da4fdc7 make --quiet not print out connection accepted SERVER-498 2009-12-20 07:17:37 -05:00
Eliot Horowitz
a0d90a4478 make --repair for a full repair 2009-12-15 20:54:02 -05:00
Eliot Horowitz
697c07f8c9 1.2.1- 2009-12-10 21:31:15 -05:00
Eliot Horowitz
2add01f37d BUMP 1.2.0 2009-12-10 10:27:04 -05:00
Aaron
0775d99ea1 SERVER-469 don't crash when authenticate called before getnonce 2009-12-10 10:16:25 -05:00
Eliot Horowitz
d6d9ce8ffe slaves can clone system.js SERVER-466 2009-12-09 10:19:11 -05:00
Eliot Horowitz
306c8c6b98 fix names 2009-12-08 12:19:09 -05:00
Eliot Horowitz
87f324edf8 prefix/postfix 2009-12-06 19:49:54 -05:00
Eliot Horowitz
89b0957a41 versions for build bot finding 2009-12-06 19:18:30 -05:00
Eliot Horowitz
05c32be539 post vs. 1.1.4 2009-12-05 11:54:52 -05:00
Eliot Horowitz
c0b78e37b5 if non master, use branch name in file 2009-12-05 11:54:36 -05:00
Eliot Horowitz
cb39613c0f better tests 2009-12-03 17:25:39 -05:00
Eliot Horowitz
ad7fc89083 BUMP 1.1.4 2009-12-03 15:03:20 -05:00
Eliot Horowitz
3c6a8cf7b7 initial stab at rpm files SERVER-396 2009-12-03 14:21:22 -05:00
71 changed files with 1216 additions and 281 deletions

3
.gitignore vendored
View File

@@ -88,7 +88,8 @@ clientTest
build-stamp
configure-stamp
debian/mongodb
debian/mongodb.*
# This was inserted 2009-08-16, nobody knows why.
#debian/mongodb.*
#osx
.DS_Store

View File

@@ -483,7 +483,7 @@ elif "win32" == os.sys.platform:
env.Append( CPPFLAGS=" /EHsc /W3 " )
env.Append( CPPFLAGS=" /wd4355 /wd4800 " ) #some warnings we don't like
env.Append( CPPDEFINES=["WIN32","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE","SUPPORT_UCP","SUPPORT_UTF8" ] )
env.Append( CPPDEFINES=["WIN32","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE","SUPPORT_UCP","SUPPORT_UTF8,PSAPI_VERSION=1" ] )
#env.Append( CPPFLAGS=' /Yu"stdafx.h" ' ) # this would be for pre-compiled headers, could play with it later
@@ -524,12 +524,14 @@ elif "win32" == os.sys.platform:
commonFiles += pcreFiles
allClientFiles += pcreFiles
winLibString = "ws2_32.lib kernel32.lib advapi32.lib"
winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib"
if force64:
winLibString += " LIBCMT LIBCPMT "
else:
winLibString += " user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib "
winLibString += " odbc32.lib odbccp32.lib uuid.lib "
env.Append( LIBS=Split(winLibString) )
if force64:
@@ -604,6 +606,29 @@ except OSError:
# --- check system ---
def getGitBranch():
if not os.path.exists( ".git" ):
return None
version = open( ".git/HEAD" ,'r' ).read().strip()
if not version.startswith( "ref: " ):
return version
version = version.split( "/" )
version = version[len(version)-1]
return version
def getGitBranchString( prefix="" , postfix="" ):
t = re.compile( '[/\\\]' ).split( os.getcwd() )
if len(t) > 2 and t[len(t)-1] == "mongo":
t = re.compile( ".*_([vV]\d+\.\d+)$" ).match( t[len(t)-2] )
if t is not None:
return prefix + t.group(1).lower() + postfix
b = getGitBranch()
if b == None or b == "master":
return ""
return prefix + b + postfix
def getGitVersion():
if not os.path.exists( ".git" ):
return "nogitversion"
@@ -818,6 +843,8 @@ def concatjs(target, source, env):
fullSource = ""
first = True
for s in source:
f = open( str(s) , 'r' )
for l in f:
@@ -825,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 )
@@ -1055,7 +1095,8 @@ def jsSpec( suffix ):
return apply( os.path.join, args )
def jsDirTestSpec( dir ):
return mongo[0].abspath + " --nodb " + jsSpec( [ dir, "*.js" ] )
tests = Glob( jsSpec( [ dir, "*.js" ] ) )
return [ mongo[0].abspath + " --nodb " + test.abspath for test in tests ]
def runShellTest( env, target, source ):
global mongodForTestsPort
@@ -1077,13 +1118,17 @@ def runShellTest( env, target, source ):
# These tests require the mongo shell
if not onlyServer and not noshell:
addSmoketest( "smokeJs", [add_exe("mongo")], runShellTest )
addSmoketest( "smokeClone", [ "mongo", "mongod" ], [ jsDirTestSpec( "clone" ) ] )
addSmoketest( "smokeRepl", [ "mongo", "mongod", "mongobridge" ], [ jsDirTestSpec( "repl" ) ] )
addSmoketest( "smokeDisk", [ add_exe( "mongo" ), add_exe( "mongod" ) ], [ jsDirTestSpec( "disk" ) ] )
addSmoketest( "smokeSharding", [ "mongo", "mongod", "mongos" ], [ jsDirTestSpec( "sharding" ) ] )
addSmoketest( "smokeClone", [ "mongo", "mongod" ], jsDirTestSpec( "clone" ) )
addSmoketest( "smokeRepl", [ "mongo", "mongod", "mongobridge" ], jsDirTestSpec( "repl" ) )
addSmoketest( "smokeDisk", [ add_exe( "mongo" ), add_exe( "mongod" ) ], jsDirTestSpec( "disk" ) )
addSmoketest( "smokeAuth", [ add_exe( "mongo" ), add_exe( "mongod" ) ], jsDirTestSpec( "auth" ) )
addSmoketest( "smokeSharding", [ "mongo", "mongod", "mongos" ], jsDirTestSpec( "sharding" ) )
addSmoketest( "smokeJsPerf", [ "mongo" ], runShellTest )
addSmoketest( "smokeQuota", [ "mongo" ], runShellTest )
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], [ jsDirTestSpec( "tool" ) ] )
if windows: # this test doesn't work on windows in v1.2.x
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], [] )
else:
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], jsDirTestSpec( "tool" ) )
mongodForTests = None
mongodForTestsPort = "27017"
@@ -1094,7 +1139,7 @@ def startMongodForTests( env, target, source ):
global mongod
if mongodForTests:
return
mongodForTestsPort = "40000"
mongodForTestsPort = "32000"
import os
ensureTestDirs()
dirName = "/data/db/sconsTests/"
@@ -1240,7 +1285,9 @@ def getDistName( sofar ):
distName = version
return version
return today.strftime( "%Y-%m-%d" )
return getGitBranchString( "" , "-" ) + today.strftime( "%Y-%m-%d" )
if distBuild:
from datetime import date
@@ -1361,7 +1408,7 @@ def s3push( localName , remoteName=None , remotePrefix=None , fixName=True , pla
if remotePrefix is None:
if distName is None:
remotePrefix = "-latest"
remotePrefix = getGitBranchString( "-" ) + "-latest"
else:
remotePrefix = "-" + distName

View File

@@ -4,7 +4,6 @@ import os;
def findHacks( un ):
if un[0] == 'Linux' and (os.path.exists("/etc/debian_version") or
os.path.exists("/etc/arch-release") or
un[3].find("Ubuntu") >= 0):
return hacks_ubuntu
return None

43
buildscripts/cleanbb.py Normal file
View File

@@ -0,0 +1,43 @@
import sys
import os
import utils
import time
def killprocs( signal="" ):
cwd = os.getcwd();
if cwd.find("buildscripts" ) > 0 :
cwd = cwd.partition( "buildscripts" )[0]
killed = 0
for x in utils.getprocesslist():
x = x.lstrip()
if x.find( cwd ) < 0:
continue
pid = x.partition( " " )[0]
print( "killing: " + x )
utils.execsys( "/bin/kill " + signal + " " + pid )
killed = killed + 1
return killed
def cleanup( root ):
# delete all regular files, directories can stay
# NOTE: if we delete directories later, we can't delete diskfulltest
for ( dirpath , dirnames , filenames ) in os.walk( root , topdown=False ):
for x in filenames:
os.remove( dirpath + "/" + x )
if killprocs() > 0:
time.sleep(3)
killprocs("-9")
if __name__ == "__main__":
root = "/data/db/"
if len( sys.argv ) > 1:
root = sys.argv[1]
cleanup( root )

View File

@@ -0,0 +1,69 @@
#!/usr/bin/python
from __future__ import with_statement
import tempfile
import sys
import re
import os
def opentemp(basename):
# The following doesn't work in python before 2.6
# return tempfile.NamedTemporaryFile('w', -1, ".XXXXXX", basename, '.', False)
fname = basename +".TMP"
if os.path.exists(fname):
raise "not clobbering file %s" % fname
return open(fname, 'w')
def frob_debian_changelog(version):
fname = 'debian/changelog'
with opentemp(fname) as o:
with open(fname) as i:
lineno = 0
for line in i:
if lineno == 0:
newline = re.sub(r'\([^)]*\)', '('+version+')', line)
o.write(newline)
else:
o.write(line)
os.rename(o.name, fname)
def frob_rpm_spec(version):
fname = 'rpm/mongo.spec'
with opentemp(fname) as o:
with open(fname) as i:
frobbed = False
for line in i:
if frobbed:
o.write(line)
else:
if line.find('Version:') == 0:
print >> o, 'Version: ' + version
frobbed = True
else:
o.write(line)
os.rename(o.name, fname)
def frob_stdafx_cpp(version):
fname = 'stdafx.cpp'
with opentemp(fname) as o:
with open(fname) as i:
frobbed = False
for line in i:
if frobbed:
o.write(line)
else:
if re.search(r'const.*char.*versionString\[\].*=', line):
o.write(' const char versionString[] = "%s";' % version)
else:
o.write(line)
os.rename(o.name, fname)
(progname, version) = sys.argv
if version is None:
print >> sys.stderr, 'usage: %s VERSION' % progname
sys.exit(1)
frob_debian_changelog(version)
frob_rpm_spec(version)
## I don't yet know what-all cares about the versionString inside the
## mongo code, so I'm not actually calling this yet.
# frob_stdafx_cpp(version)

View File

@@ -42,6 +42,6 @@ def foundxulrunner( env , options ):
incroot + "unstable/" ] )
env.Append( CPPDEFINES=[ "XULRUNNER" , "OLDJS" ] )
if best.find( "1.9.0" ) >= 0:
if best.find( "1.9.0" ) >= 0 or best.endswith("1.9"):
env.Append( CPPDEFINES=[ "XULRUNNER190" ] )
return True

23
buildscripts/utils.py Normal file
View File

@@ -0,0 +1,23 @@
import re
# various utilities that are handy
def execsys( args ):
import subprocess
if isinstance( args , str ):
r = re.compile( "\s+" )
args = r.split( args )
p = subprocess.Popen( args , stdout=subprocess.PIPE , stderr=subprocess.PIPE )
r = p.communicate()
return r;
def getprocesslist():
raw = ""
try:
raw = execsys( "/bin/ps -ax" )[0]
except Exception,e:
print( "can't get processlist: " + str( e ) )
r = re.compile( "[\r\n]+" )
return r.split( raw )

View File

@@ -16,6 +16,7 @@
*/
#include "../stdafx.h"
#include "../db/cmdline.h"
namespace mongo {
@@ -23,6 +24,8 @@ namespace mongo {
bool quiet = false;
CmdLine cmdLine;
// Database* database = 0;
bool dbexitCalled = false;

View File

@@ -465,6 +465,10 @@ namespace mongo {
assert(false);
}
found:
deallocBucket( thisLoc );
}
void BtreeBucket::deallocBucket(const DiskLoc &thisLoc) {
#if 1
/* as a temporary defensive measure, we zap the whole bucket, AND don't truly delete
it (meaning it is ineligible for reuse).
@@ -1003,20 +1007,27 @@ namespace mongo {
BSONObj k;
DiskLoc r;
x->popBack(r,k);
if( x->n == 0 )
log() << "warning: empty bucket on BtreeBuild " << k.toString() << endl;
bool keepX = ( x->n != 0 );
DiskLoc keepLoc = keepX ? xloc : x->nextChild;
if ( ! up->_pushBack(r, k, order, xloc) ){
if ( ! up->_pushBack(r, k, order, keepLoc) ){
// current bucket full
DiskLoc n = BtreeBucket::addBucket(idx);
up->tempNext() = n;
upLoc = n;
up = upLoc.btreemod();
up->pushBack(r, k, order, xloc);
up->pushBack(r, k, order, keepLoc);
}
xloc = x->tempNext(); /* get next in chain at current level */
x->parent = upLoc;
DiskLoc nextLoc = x->tempNext(); /* get next in chain at current level */
if ( keepX ) {
x->parent = upLoc;
} else {
if ( !x->nextChild.isNull() )
x->nextChild.btreemod()->parent = upLoc;
x->deallocBucket( xloc );
}
xloc = nextLoc;
}
loc = upStart;

View File

@@ -88,7 +88,9 @@ namespace mongo {
protected:
void modified(const DiskLoc& thisLoc);
KeyNode keyNode(int i) const {
assert( i < n );
if ( i >= n ){
massert( (string)"invalid keyNode: " + BSON( "i" << i << "n" << n ).jsonString() , i < n );
}
return KeyNode(*this, k(i));
}
@@ -185,6 +187,7 @@ namespace mongo {
bool exists(const IndexDetails& idx, DiskLoc thisLoc, const BSONObj& key, BSONObj order);
static DiskLoc addBucket(IndexDetails&); /* start a new index off, empty */
void deallocBucket(const DiskLoc &thisLoc); // clear bucket memory, placeholder for deallocation
static void renameIndexNamespace(const char *oldNs, const char *newNs);

View File

@@ -103,7 +103,7 @@ namespace mongo {
/* must call when a btree bucket going away.
note this is potentially slow
*/
inline void ClientCursor::informAboutToDeleteBucket(const DiskLoc& b) {
void ClientCursor::informAboutToDeleteBucket(const DiskLoc& b) {
recursive_boostlock lock(ccmutex);
RARELY if ( byLoc.size() > 70 ) {
log() << "perf warning: byLoc.size=" << byLoc.size() << " in aboutToDeleteBucket\n";

View File

@@ -216,7 +216,7 @@ namespace mongo {
if( strstr(from_name, ".system.") ) {
/* system.users is cloned -- but nothing else from system. */
if( strstr(from_name, ".system.users") == 0 ){
if( legalClientSystemNS( from_name , true ) == 0 ){
log(2) << "\t\t not cloning because system collection" << endl;
continue;
}

View File

@@ -113,9 +113,16 @@ namespace mongo {
virtual void accepted(MessagingPort *mp) {
assert( grab == 0 );
grab = mp;
boost::thread thr(connThread);
while ( grab )
sleepmillis(1);
try {
boost::thread thr(connThread);
while ( grab )
sleepmillis(1);
}
catch ( boost::thread_resource_error& e ){
log() << "can't create new thread, closing connection" << endl;
mp->shutdown();
grab = 0;
}
}
};
@@ -283,7 +290,7 @@ namespace mongo {
bool doDBUpgrade( const string& dbName , string errmsg , MDFHeader * h ){
static DBDirectClient db;
if ( h->version == 4 && h->versionMinor == 4 ){
if ( forceRepair == false && h->version == 4 && h->versionMinor == 4 ){
assert( VERSION == 4 );
assert( VERSION_MINOR == 5 );
@@ -347,6 +354,7 @@ namespace mongo {
if ( shouldRepairDatabases ){
log() << "finished checking dbs" << endl;
cc().shutdown();
dbexit( EXIT_CLEAN );
}
}

View File

@@ -308,18 +308,24 @@ namespace mongo {
}
{
BSONObjBuilder t( result.subobjStart( "mem" ) );
ProcessInfo p;
if ( p.supported() ){
BSONObjBuilder t;
t.append( "resident" , p.getResidentSize() );
t.append( "virtual" , p.getVirtualMemorySize() );
t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
result.append( "mem" , t.obj() );
t.appendBool( "supported" , true );
}
else {
result.append( "mem" , "not support on this platform" );
result.append( "note" , "not all mem info support on this platform" );
t.appendBool( "supported" , false );
}
t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
t.done();
}
return true;

View File

@@ -104,13 +104,13 @@ namespace mongo {
return true;
}
bool Helpers::findById(const char *ns, BSONObj query, BSONObj& result ){
int Helpers::findById(const char *ns, BSONObj query, BSONObj& result ){
NamespaceDetails *d = nsdetails(ns);
if ( ! d )
return false;
return -1;
int idxNo = d->findIdIndex();
if ( idxNo < 0 )
return false;
return -1;
IndexDetails& i = d->idx( idxNo );
BSONObj key = i.getKeyFromQuery( query );

View File

@@ -49,7 +49,12 @@ namespace mongo {
*/
static bool findOne(const char *ns, BSONObj query, BSONObj& result, bool requireIndex = false);
static bool findById(const char *ns, BSONObj query, BSONObj& result );
/**
-1 no index
0 not found
1 found
*/
static int findById(const char *ns, BSONObj query, BSONObj& result );
/* Get/put the first object from a collection. Generally only useful if the collection
only ever has a single object -- which is a "singleton collection".

View File

@@ -88,10 +88,20 @@ namespace mongo {
_cur = new InMemory();
}
_cur->push_back( pair<BSONObj,DiskLoc>( o.getOwned() , loc ) );
BSONObj toadd = o;
if ( toadd.isOwned() ){
// hack to handle buffer problems
if ( toadd.objsize() < 100 )
toadd = toadd.copy();
}
else {
toadd = toadd.getOwned();
}
_cur->push_back( pair<BSONObj,DiskLoc>( o , loc ) );
long size = o.objsize();
_curSizeSoFar += size + sizeof( DiskLoc );
_curSizeSoFar += size + sizeof( DiskLoc ) + sizeof( BSONObj );
if ( _curSizeSoFar > _maxFilesize )
finishMap();
@@ -204,7 +214,8 @@ namespace mongo {
BSONObjExternalSorter::FileIterator::FileIterator( string file ){
long length;
_buf = (char*)_file.map( file.c_str() , length );
_buf = (char*)_file.map( file.c_str() , length , MemoryMappedFile::SEQUENTIAL );
massert( "mmap failed" , _buf );
assert( (unsigned long)length == file_size( file ) );
_end = _buf + length;
}

View File

@@ -43,7 +43,7 @@ namespace mongo {
if ( ! f && level ){
log() << "diagLogging = " << level << endl;
stringstream ss;
ss << "diaglog." << hex << time(0);
ss << dbpath << "/diaglog." << hex << time(0);
string name = ss.str();
f = new ofstream(name.c_str(), ios::out | ios::binary);
if ( ! f->good() ) {

View File

@@ -714,8 +714,15 @@ namespace mongo {
_holder.reset( new Holder( data ) );
_objdata = data;
if ( ! isValid() ){
log() << "invalid object size: " << objsize() << endl;
massert( "Invalid BSONObj spec size" , 0 );
stringstream ss;
ss << "Invalid BSONObj spec size: " << objsize();
try {
BSONElement e = firstElement();
ss << " first element:" << e.toString() << " ";
}
catch ( ... ){}
string s = ss.str();
massert( s , 0 );
}
}
#pragma pack(1)

View File

@@ -103,7 +103,6 @@ namespace mongo {
if ( ! _needRecord ){
return true;
}
return _recordMatcher.matches(recLoc.rec());
}

View File

@@ -205,7 +205,13 @@ namespace mongo {
scope->localConnect( setup.dbname.c_str() );
map = scope->createFunction( setup.mapCode.c_str() );
if ( ! map )
throw UserException( (string)"map compile failed: " + scope->getError() );
reduce = scope->createFunction( setup.reduceCode.c_str() );
if ( ! reduce )
throw UserException( (string)"reduce compile failed: " + scope->getError() );
if ( setup.finalizeCode.size() )
finalize = scope->createFunction( setup.finalizeCode.c_str() );
else

View File

@@ -445,9 +445,14 @@ namespace mongo {
// signal done allocating new extents.
if ( !deletedList[ 1 ].isValid() )
deletedList[ 1 ] = DiskLoc();
assert( len < 400000000 );
int passes = 0;
int maxPasses = ( len / 30 ) + 2; // 30 is about the smallest entry that could go in the oplog
if ( maxPasses < 5000 ){
// this is for bacwards safety since 5000 was the old value
maxPasses = 5000;
}
DiskLoc loc;
// delete records until we have room and the max # objects limit achieved.
@@ -496,10 +501,10 @@ namespace mongo {
DiskLoc fr = theCapExtent()->firstRecord;
theDataFileMgr.deleteRecord(ns, fr.rec(), fr, true);
compact();
if( ++passes >= 5000 ) {
log() << "passes ns:" << ns << " len:" << len << '\n';
if( ++passes > maxPasses ) {
log() << "passes ns:" << ns << " len:" << len << " maxPasses: " << maxPasses << '\n';
log() << "passes max:" << max << " nrecords:" << nrecords << " datasize: " << datasize << endl;
massert( "passes >= 5000 in capped collection alloc", false );
massert( "passes >= maxPasses in capped collection alloc", false );
}
}

View File

@@ -774,9 +774,9 @@ namespace mongo {
try {
ok = id.head.btree()->unindex(id.head, id, j, dl);
}
catch (AssertionException&) {
catch (AssertionException& e) {
problem() << "Assertion failure: _unindex failed " << id.indexNamespace() << endl;
out() << "Assertion failure: _unindex failed" << '\n';
out() << "Assertion failure: _unindex failed: " << e.what() << '\n';
out() << " obj:" << obj.toString() << '\n';
out() << " key:" << j.toString() << '\n';
out() << " dl:" << dl.toString() << endl;

View File

@@ -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 {
@@ -771,26 +778,31 @@ namespace mongo {
uassert("bad query object", false);
}
int idxHackWorked = false;
if ( strcmp( query.firstElement().fieldName() , "_id" ) == 0 && query.nFields() == 1 && query.firstElement().isSimpleType() ){
nscanned = 1;
BSONObj resObject;
bool found = Helpers::findById( ns , query , resObject );
if ( found ){
n = 1;
fillQueryResultFromObj( bb , filter.get() , resObject );
}
qr.reset( (QueryResult *) bb.buf() );
bb.decouple();
qr->resultFlags() = 0;
qr->len = bb.len();
ss << " reslen:" << bb.len();
qr->setOperation(opReply);
qr->cursorId = cursorid;
qr->startingFrom = 0;
qr->nReturned = n;
int found = Helpers::findById( ns , query , resObject );
if ( found >= 0 ){
idxHackWorked = true;
if ( found ){
n = 1;
fillQueryResultFromObj( bb , filter.get() , resObject );
}
qr.reset( (QueryResult *) bb.buf() );
bb.decouple();
qr->resultFlags() = 0;
qr->len = bb.len();
ss << " reslen:" << bb.len();
qr->setOperation(opReply);
qr->cursorId = cursorid;
qr->startingFrom = 0;
qr->nReturned = n;
}
}
else { // non-simple _id lookup
if ( ! idxHackWorked ){
BSONObj oldPlan;
if ( explain && hint.eoo() && min.isEmpty() && max.isEmpty() ) {
QueryPlanSet qps( ns, query, order );

View File

@@ -860,7 +860,7 @@ namespace mongo {
if ( replAllDead ) {
// hmmm why is this check here and not at top of this function? does it get set between top and here?
log() << "replAllDead, throwing SyncException\n";
log() << "replAllDead, throwing SyncException: " << replAllDead << endl;
throw SyncException();
}
@@ -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 );
@@ -1585,7 +1589,8 @@ namespace mongo {
stringstream ss;
ss << "repl: sleep " << s << "sec before next pass";
string msg = ss.str();
log() << msg << endl;
if ( ! cmdLine.quiet )
log() << msg << endl;
ReplInfo r(msg.c_str());
sleepsecs(s);
}

View File

@@ -97,11 +97,17 @@ namespace mongo {
stringstream digestBuilder;
{
bool reject = false;
nonce *ln = lastNonce.release();
digestBuilder << hex << *ln;
if( ln == 0 || digestBuilder.str() != received_nonce ) {
log() << "auth: bad nonce received. could be a driver bug or a security attack. db:" << cc().database()->name << '\n';
if ( ln == 0 ) {
reject = true;
} else {
digestBuilder << hex << *ln;
reject = digestBuilder.str() != received_nonce;
}
if ( reject ) {
log() << "auth: bad nonce received or getnonce not called. could be a driver bug or a security attack. db:" << cc().database()->name << '\n';
errmsg = "auth fails";
sleepmillis(30);
return false;

View File

@@ -248,6 +248,8 @@ namespace mongo {
if ( !( e.isNumber() && m.elt.isNumber() ) &&
m.elt.valuesize() != e.valuesize() )
inPlacePossible = false;
if ( e.type() != m.elt.type() )
inPlacePossible = false;
break;
case Mod::PUSH:
case Mod::PUSH_ALL:

View File

@@ -110,6 +110,27 @@ namespace BasicTests {
roundTrip( y , 40 );
}
};
class sleeptest {
public:
void run(){
Timer t;
sleepsecs( 1 );
ASSERT_EQUALS( 1 , t.seconds() );
t.reset();
sleepmicros( 1527123 );
ASSERT( t.micros() > 1000000 );
ASSERT( t.micros() < 2000000 );
t.reset();
sleepmillis( 1727 );
ASSERT( t.millis() >= 1000 );
ASSERT( t.millis() <= 2000 );
}
};
class All : public Suite {
public:
@@ -119,6 +140,8 @@ namespace BasicTests {
void setupTests(){
add< Rarely >();
add< Base64Tests >();
add< sleeptest >();
}
} myall;

View File

@@ -82,6 +82,20 @@ namespace ClientTests {
};
class CS_10 : public Base {
public:
CS_10() : Base( "CS_10" ) {}
void run() {
string longs( 770, 'c' );
for( int i = 0; i < 11; ++i )
db.insert( ns(), BSON( "a" << i << "b" << longs ) );
db.ensureIndex( ns(), BSON( "a" << 1 << "b" << 1 ) );
auto_ptr< DBClientCursor > c = db.query( ns(), Query().sort( BSON( "a" << 1 << "b" << 1 ) ), 2 );
ASSERT_EQUALS( 11, c->itcount() );
}
};
class All : public Suite {
public:
@@ -92,6 +106,7 @@ namespace ClientTests {
add<DropIndex>();
add<ReIndex>();
add<ReIndex2>();
add<CS_10>();
}
} all;

View File

@@ -112,7 +112,7 @@ namespace CursorTests {
}
};
} // namespace MultiBtreeCursorTests
} // namespace BtreeCursorTests
class All : public Suite {
public:

View File

@@ -1185,6 +1185,40 @@ namespace JsobjTests {
}
};
class InvalidIDFind {
public:
void run(){
BSONObj x = BSON( "_id" << 5 << "t" << 2 );
{
char * crap = (char*)malloc( x.objsize() );
memcpy( crap , x.objdata() , x.objsize() );
BSONObj y( crap , false );
ASSERT_EQUALS( x , y );
free( crap );
}
{
char * crap = (char*)malloc( x.objsize() );
memcpy( crap , x.objdata() , x.objsize() );
int * foo = (int*)crap;
foo[0] = 123123123;
int state = 0;
try {
BSONObj y( crap , false );
state = 1;
}
catch ( std::exception& e ){
state = 2;
ASSERT( strstr( e.what() , "_id: 5" ) > 0 );
}
free( crap );
ASSERT_EQUALS( 2 , state );
}
}
};
class All : public Suite {
public:
All() : Suite( "jsobj" ){
@@ -1269,6 +1303,7 @@ namespace JsobjTests {
add< BSONArrayBuilderTest >();
add< ArrayMacroTest >();
add< NumberParsing >();
add< InvalidIDFind >();
}
} myall;

View File

@@ -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() );
}
};

16
debian/changelog vendored
View File

@@ -1,4 +1,18 @@
mongodb (1.1.3) unstable; urgency=low
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
-- Richard Kreuter <richard@10gen.com> Fri, 05 Feb 2010 16:56:28 -0500
mongodb (1.2.2) unstable; urgency=low
* Initial release

6
debian/control vendored
View File

@@ -1,14 +1,14 @@
Source: mongodb
Section: devel
Priority: optional
Maintainer: Kristina Chodorow <kristina@10gen.com>
Build-Depends: debhelper (>= 7), libboost-dev, libpcre3, libpcre3-dev, scons, xulrunner-1.9-dev, libboost-thread-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-date-time-dev
Maintainer: Richard Kreuter <richard@10gen.com>
Build-Depends: debhelper (>= 7), libpcre3, libpcre3-dev, scons, xulrunner-dev, libboost1.35-dev | libboost1.37-dev | libboost1.38-dev | libboost1.40-dev, libboost-thread1.35-dev | libboost-thread1.37-dev | libboost-thread1.38-dev | libboost-thread1.40-dev, libboost-filesystem1.35-dev | libboost-filesystem1.37-dev | libboost-filesystem1.38-dev | libboost-filesystem1.40-dev, libboost-program-options1.35-dev | libboost-program-options1.37-dev | libboost-program-options1.38-dev | libboost-program-options1.40-dev, libboost-date-time1.35-dev | libboost-date-time1.37-dev | libboost-date-time1.38-dev | libboost-date-time1.40-dev, libpcap-dev, libreadline-dev
Standards-Version: 3.8.0
Homepage: http://www.mongodb.org
Package: mongodb
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-1.9-dev
Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-dev
Description: An object/document-oriented database
MongoDB is a high-performance, open source, schema-free
document-oriented data store that's easy to deploy, manage

98
debian/init.d vendored
View File

@@ -21,8 +21,8 @@
#
### BEGIN INIT INFO
# Provides: mongodb
# Required-Start: $network $local_fs
# Required-Stop:
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $named
# Should-Stop:
# Default-Start: 2 3 4 5
@@ -48,10 +48,21 @@
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/mongod
DATA=/var/lib/mongodb
NAME=MongoDB
DESC=database
# Default defaults. Can be overridden by the /etc/default/$NAME
NAME=mongodb
CONF=/etc/mongodb.conf
DATA=/var/lib/mongodb
LOGDIR=/var/log/mongodb
PIDFILE=/var/run/$NAME.pid
LOGFILE=$LOGDIR/$NAME.log # Server logfile
# Include mongodb defaults if available
if [ -f /etc/default/$NAME ] ; then
. /etc/default/$NAME
fi
if test ! -x $DAEMON; then
echo "Could not find $DAEMON"
exit 0
@@ -63,35 +74,15 @@ fi
. /lib/lsb/init-functions
LOGDIR=/var/log/mongodb
PIDFILE=/var/run/$NAME.pid
STARTTIME=1
DIETIME=10 # Time to wait for the server to die, in seconds
# If this value is set too low you might not
# let some servers to die gracefully and
# 'restart' will not work
LOGFILE=$LOGDIR/$NAME.log # Server logfile
DAEMON_OPTS="--dbpath $DATA --logpath $LOGFILE run"
# Include mongodb defaults if available
if [ -f /etc/default/$NAME ] ; then
. /etc/default/$NAME
fi
DAEMONUSER=mongodb
# Check that the user exists (if we set a user)
# Does the user exist?
if [ -n "$DAEMONUSER" ] ; then
if getent passwd | grep -q "^$DAEMONUSER:"; then
# Obtain the uid and gid
DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
else
log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
exit 1
fi
fi
DAEMONUSER=${DAEMONUSER:-mongodb}
DAEMON_OPTS=${DAEMON_OPTS:-"--dbpath $DATA --logpath $LOGFILE run"}
DAEMON_OPTS="$DAEMON_OPTS --config $CONF"
set -e
@@ -121,45 +112,22 @@ running() {
start_server() {
# Start the process using the wrapper
if [ -z "$DAEMONUSER" ] ; then
start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
--make-pidfile --exec $DAEMON -- $DAEMON_OPTS
errcode=$?
else
# if we are using a daemonuser then change the user id
start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
--make-pidfile --chuid $DAEMONUSER \
--exec $DAEMON -- $DAEMON_OPTS
errcode=$?
fi
return $errcode
}
stop_server() {
# Stop the process using the wrapper
if [ -z "$DAEMONUSER" ] ; then
start-stop-daemon --stop --quiet --pidfile $PIDFILE
rm $PIDFILE
errcode=$?
else
# if we are using a daemonuser then look for process that match
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
--user $DAEMONUSER \
--exec $DAEMON
errcode=$?
fi
return $errcode
}
reload_server() {
[ ! -f "$PIDFILE" ] && return 1
pid=pidofproc $PIDFILE # This is the daemon's pid
# Send a SIGHUP
kill -USR1 $pid
return $?
}
force_stop() {
# Force the process to die killing it manually
[ ! -e "$PIDFILE" ] && return
@@ -182,7 +150,7 @@ force_stop() {
case "$1" in
start)
log_daemon_msg "Starting $DESC $NAME"
log_daemon_msg "Starting $DESC" "$NAME"
# Check if it's running first
if running ; then
log_progress_msg "apparently already running"
@@ -254,35 +222,11 @@ case "$1" in
exit 1
fi
;;
# Use this if the daemon cannot reload
# MongoDB can't reload its configuration.
reload)
log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
log_warning_msg "cannot re-read the config file (use restart)."
;;
# And this if it cann
#reload)
#
# If the daemon can reload its config files on the fly
# for example by sending it SIGHUP, do it here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this a do-nothing entry.
#
# log_daemon_msg "Reloading $DESC configuration files" "$NAME"
# if running ; then
# reload_server
# if ! running ; then
# Process died after we tried to reload
# log_progress_msg "died on reload"
# log_end_msg 1
# exit 1
# fi
# else
# log_progress_msg "server is not running"
# log_end_msg 1
# exit 1
# fi
#;;
*)
N=/etc/init.d/$NAME

11
debian/lintian-overrides vendored Normal file
View File

@@ -0,0 +1,11 @@
# Agreed with upstream, that redefining rpath is necessary as xulrunner used to
# change API without changing so-name
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongo /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongod /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongodump /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongoexport /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongofiles /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongoimport /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongorestore /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongos /usr/lib64/xulrunner-1.9.1
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongosniff /usr/lib64/xulrunner-1.9.1

16
debian/mongod.1 vendored Normal file
View File

@@ -0,0 +1,16 @@
.\" Documentation for the MongoDB shell
.TH MONGOD "1" "June 2009" "10gen" "Mongo Database"
.SH "NAME"
mongod \- the Mongo Daemon
.SH "SYNOPSIS"
.SH "DESCRIPTION"
.PP
\fBmongod\fR
is a core MongoDB daemon. You are not supposed to call it directly, please refer to the wiki if necessary.
.SH "COPYRIGHT"
.PP
Copyright 2007\-2009 10gen
.SH "SEE ALSO"
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
.SH "AUTHOR"
Antonin Kral

95
debian/mongodb.conf vendored Normal file
View File

@@ -0,0 +1,95 @@
# mongodb.conf
# Where to store the data.
# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/var/lib/mongodb
#where to log
logpath=/var/log/mongodb/mongodb.log
logappend=true
#port = 27017
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#oplog = 0
# Diagnostic/debugging option
#nocursors = true
# Ignore query hints
#nohints = true
# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Accout token for Mongo monitoring server.
#mms-token = <token>
# Server name for Mongo monitoring server.
#mms-name = <server-name>
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
# Address of a server to pair with.
#pairwith = <server:port>
# Address of arbiter server.
#arbiter = <server:port>
# Automatically resync if slave data is stale
#autoresync
# Custom size for replication operation log.
#oplogSize = <MB>
# Size limit for in-memory storage of op ids.
#opIdMem = <bytes>

12
debian/mongodb.upstart vendored Normal file
View File

@@ -0,0 +1,12 @@
# Ubuntu upstart file at /etc/init/mongodb.conf
pre-start script
mkdir -p /var/lib/mongodb/
mkdir -p /var/log/mongodb/
end script
start on runlevel [2345]
stop on runlevel [06]
exec start-stop-daemon --start --quiet --chuid mongodb --exec /usr/bin/mongod -- --config /etc/mongodb.conf

63
debian/mongoimport.1 vendored Normal file
View File

@@ -0,0 +1,63 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
.TH MONGOIMPORT "1" "January 2010" "10gen" "Mongo Database"
.SH "NAME"
mongoimport \- the Mongo import tool
.SH "SYNOPSIS"
\fBmongoimport [\fIOPTIONS\fR]\fR
.SH "DESCRIPTION"
.PP
\fBmongoimport\fR
is a tool to import a MongoDB collection from JSON, CSV, or TSV. The query can be filtered or a list of fields to input can be given.
.\".SH "EXAMPLES"
.\".TP
.\".B mongoimport -d test -c test1 --csv -f "name,num"
.\"import documents from test.test1 in CSV format
.SS "OPTIONS"
.TP
\fB\-\-help\fR
show usage information
.TP
.B \-h, \-\-host HOST
server to connect to (default HOST=localhost)
.TP
.B \-d, \-\-db DATABASE
database to use
.TP
.B \-c, \-\-c COLLECTION
collection to use (some commands)
.TP
.B \-\-dbpath PATH
directly access mongod data files in this path,
instead of connecting to a mongod instance
.TP
.B \-v, \-\-verbose
be more verbose (include multiple times for more
verbosity e.g. \fB\-vvvvv\fR)
.TP
.B \-f, \-\-fields NAMES
comma seperated list of field names e.g. \fB\-f\fR name,age
.TP
.B \-\-fieldFile FILE
file with fields names \- 1 per line
.TP
.B \-\-ignoreBlanks
if given, empty fields in csv and tsv will be ignored
.TP
.B \-\-type TYPE
type of file to import. default: json (json,csv,tsv)
.TP
.B \-\-file FILE
file to import from; if not specified stdin is used
.TP
.B \-\-drop
drop collection first
.TP
.B \-\-headerline
CSV,TSV only \- use first line as headers
.SH "COPYRIGHT"
.PP
Copyright 2007\-2009 10gen
.SH "SEE ALSO"
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
.SH "AUTHOR"
Kristina Chodorow

View File

@@ -1,45 +0,0 @@
.\" Documentation for the MongoDB shell
.TH MONGOIMPORTJSON "1" "June 2009" "10gen" "Mongo Database"
.SH "NAME"
mongoimportjson \- the Mongo import tool
.SH "SYNOPSIS"
\fBmongoimportjson [\fIOPTIONS\fR]\fR
.SH "DESCRIPTION"
.PP
\fBmongoimportjson\fR
is a tool to import JSON documents into MongoDB. This utility takes a single file that contains one JSON string per line and inserts it. A databaase and collection must be specified.
.SH "OPTIONS"
.TP
.B \-\-help
show usage information
.TP
.B \-h, \-\-host HOST
server to connect to (default HOST=localhost)
.TP
.B \-d, \-\-db DATABASE
database to use
.TP
.B \-c, \-\-c COLLECTION
collection to use
.TP
.B \-\-file FILE
file from which to import
.TP
.B \-\-dbpath PATH
directly access mongod data files in this path, instead of connecting to a mongod instance
.TP
.B \-\-idbefore
create id index before importing
.TP
.B \-\-id
create id index after importing (recommended)
.TP
.B \-\-drop
drop collection before importing
.SH "COPYRIGHT"
.PP
Copyright 2007\-2009 10gen
.SH "SEE ALSO"
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
.SH "AUTHOR"
Kristina Chodorow

30
debian/mongosniff.1 vendored Normal file
View File

@@ -0,0 +1,30 @@
.TH MONGOSNIFF "1" "Jan 2010" "10gen" "Mongo Database"
.SH "NAME"
mongosniff \- the Mongo packet analyzer
.SH "SYNOPSIS"
\fBmongosniff [\fIOPTIONS\fR] [\fI<port0> <port1> ...\fR]
.SH "DESCRIPTION"
.PP
\fBmongosniff\fR
is a analyzer tool for analyzing packets coming to your database.
.PP
.SH "OPTIONS"
.TP
.B \-\-forward
Forward all parsed request messages to mongod instance at specified host:port
.TP
.B \-\-source
Source of traffic to sniff, either a network interface or a file containing previously captured packets, in pcap format. If no source is specified, mongosniff will attempt to sniff from one of the machine's network interfaces.
.TP
.B \-\-help
print a short help message.
.TP
.B <port0>
These parameters are used to filter sniffing. By default, only port 27017 is sniffed.
.SH "COPYRIGHT"
.PP
Copyright 2007\-2009 10gen
.SH "SEE ALSO"
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
.SH "AUTHOR"
Antonin Kral

10
debian/postinst vendored
View File

@@ -22,18 +22,18 @@ case "$1" in
configure)
# create a mongodb group and user
if ! grep -q mongodb /etc/passwd; then
adduser --system mongodb
adduser --system --no-create-home mongodb
addgroup --system mongodb
adduser mongodb mongodb
fi
# create db
# 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
# 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)

18
debian/rules vendored
View File

@@ -26,6 +26,7 @@ build-stamp: configure-stamp
# Add here commands to compile the package.
scons
#docbook-to-man debian/mongodb.sgml > mongodb.1
ls debian/*.1 > debian/mongodb.manpages
touch $@
@@ -34,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
@@ -49,16 +53,24 @@ clean:
rm -rf tools/*.o
rm -rf shell/*.o
rm -rf .sconf_temp
dh_clean
rm -f buildscripts/*.pyc
rm -f *.pyc
rm -f buildinfo.cpp
dh_clean debian/files
install: build
dh_testdir
dh_testroot
dh_clean -k
dh_prep
dh_installdirs
scons --prefix=$(CURDIR)/debian/mongodb/usr install
mkdir -p $(CURDIR)/debian/mongodb/etc
cp $(CURDIR)/debian/mongodb.conf $(CURDIR)/debian/mongodb/etc/mongodb.conf
mkdir -p $(CURDIR)/debian/mongodb/usr/share/lintian/overrides/
install -m 644 $(CURDIR)/debian/lintian-overrides \
$(CURDIR)/debian/mongodb/usr/share/lintian/overrides/mongodb
# Build architecture-independent files here.
binary-indep: build install

View File

@@ -3,7 +3,7 @@
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = MongoDB
PROJECT_NUMBER = 1.1.3
PROJECT_NUMBER = 1.2.4
OUTPUT_DIRECTORY = docs
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English

0
jstests/auth/dummy.js Normal file
View File

11
jstests/auth2.js Normal file
View File

@@ -0,0 +1,11 @@
db2 = new Mongo( db.getMongo().host ).getDB( db.getName() );
users = db2.getCollection( "system.users" );
users.remove( {} );
pass = "a" + Math.random();
//print( "password [" + pass + "]" );
db2.addUser( "eliot" , pass );
assert.commandFailed( db2.runCommand( { authenticate: 1, user: "eliot", nonce: "foo", key: "bar" } ) );

View File

@@ -134,7 +134,7 @@ if ( true ){
print( "t1: " + Date.timeFunc(
function(){
var out = db.runCommand( { mapreduce : "mr1" , map : m , reduce : r } );
if ( ks == "_id" ) assert( out.ok , "XXX" );
if ( ks == "_id" ) assert( out.ok , "XXX : " + tojson( out ) );
db[out.result].drop();
} , 10 ) + " (~500 on 2.8ghz) - itcount: " + Date.timeFunc( function(){ db.mr1.find().itcount(); } , 10 ) );

View File

@@ -0,0 +1,47 @@
t = db.mr_errorhandling;
t.drop();
t.save( { a : [ 1 , 2 , 3 ] } )
t.save( { a : [ 2 , 3 , 4 ] } )
m_good = function(){
for ( var i=0; i<this.a.length; i++ ){
emit( this.a[i] , 1 );
}
}
m_bad = function(){
for ( var i=0; i<this.a.length; i++ ){
emit( this.a[i] );
}
}
r = function( k , v ){
var total = 0;
for ( var i=0; i<v.length; i++ )
total += v[i];
return total;
}
res = t.mapReduce( m_good , r );
assert.eq( { 1 : 1 , 2 : 2 , 3 : 2 , 4 : 1 } , res.convertToSingleObject() , "A" );
res.drop()
res = null;
theerror = null;
try {
res = t.mapReduce( m_bad , r );
}
catch ( e ){
theerror = e.toString();
}
assert.isnull( res , "B1" );
assert( theerror , "B2" );
assert( theerror.indexOf( "emit" ) >= 0 , "B3" );
// test things are still in an ok state
res = t.mapReduce( m_good , r );
assert.eq( { 1 : 1 , 2 : 2 , 3 : 2 , 4 : 1 } , res.convertToSingleObject() , "A" );
res.drop()

View File

@@ -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();

View File

@@ -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();

View File

@@ -12,6 +12,8 @@ assert.eq( 0 , s.count() , "setup - D" );
s.save( { _id : "x" , value : "4" } );
assert.eq( 1 , s.count() , "setup - E" );
assert.eq( 4 , s.findOne( { _id : "x" } ).value , "E2 " );
assert.eq( 4 , s.findOne().value , "setup - F" );
s.update( { _id : "x" } , { $set : { value : 5 } } );
assert.eq( 1 , s.count() , "setup - G" );
@@ -29,3 +31,5 @@ assert.eq( 6 , db.eval( "return x" ) , "exec - 2 " );
s.insert( { _id : "bar" , value : function( z ){ return 17 + z; } } );
assert.eq( 22 , db.eval( "return bar(5);" ) , "exec - 3 " );

View File

@@ -208,6 +208,7 @@
93A6E10D0F24CFB100DA4EBF /* flushtest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flushtest.cpp; sourceTree = "<group>"; };
93A6E10E0F24CFD300DA4EBF /* security.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = security.h; sourceTree = "<group>"; };
93A6E10F0F24CFEA00DA4EBF /* security_commands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = security_commands.cpp; sourceTree = "<group>"; };
93A71D2D10D04D15003C9E90 /* auth2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = auth2.js; sourceTree = "<group>"; };
93A8CD170F33B78D00C92B85 /* mmap_mm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_mm.cpp; path = util/mmap_mm.cpp; sourceTree = SOURCE_ROOT; };
93A8CD180F33B7A000C92B85 /* mmap_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_posix.cpp; path = util/mmap_posix.cpp; sourceTree = SOURCE_ROOT; };
93A8CD190F33B7AF00C92B85 /* mmap_win.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_win.cpp; path = util/mmap_win.cpp; sourceTree = SOURCE_ROOT; };
@@ -641,6 +642,7 @@
93A8D1D10F37544800C92B85 /* jstests */ = {
isa = PBXGroup;
children = (
93A71D2D10D04D15003C9E90 /* auth2.js */,
935E7B8A0FCF37D40024B2E5 /* sharding */,
936D937F0FCC67C700004410 /* index9.js */,
936D931B0FCC58C900004410 /* regex.js */,

63
rpm/init.d-mongod Normal file
View File

@@ -0,0 +1,63 @@
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongo/mongo.pid
. /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
OPTIONS=" -f /etc/mongod.conf"
mongod=${MONGOD-/usr/bin/mongod}
pidfile=${PIDFILE-/var/run/mongod.pid}
lockfile=${LOCKFILE-/var/lock/subsys/mongod}
start()
{
echo -n $"Starting mongod: "
#daemon --pidfile=${pidfile} $mongod $OPTIONS > /var/log/mongod
$mongod $OPTIONS > /var/log/mongod 2>&1 &
RETVAL=$?
[ $RETVAL = 0 ] && touch ${lockfile}
echo OK
}
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
}
ulimit -n 12000
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
# status)
# status -p ${pidfile} $mongod
# ;;
*)
echo $"Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL

128
rpm/mongo.spec Normal file
View File

@@ -0,0 +1,128 @@
Name: mongo
Version: 1.2.4
Release: mongodb_1%{?dist}
Summary: mongo client shell and tools
License: AGPL 3.0
URL: http://www.mongodb.org
Group: Applications/Databases
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: js-devel, readline-devel, boost-devel, pcre-devel
BuildRequires: gcc-c++, scons
%description
Mongo (from "huMONGOus") is a schema-free document-oriented database.
It features dynamic profileable queries, full indexing, replication
and fail-over support, efficient storage of large binary data objects,
and auto-sharding.
This package provides the mongo shell, import/export tools, and other
client utilities.
%package server
Summary: mongo server, sharding server, and support scripts
Group: Applications/Databases
%description server
Mongo (from "huMONGOus") is a schema-free document-oriented database.
This package provides the mongo server software, mongo sharding server
softwware, default configuration files, and init.d scripts.
%package devel
Summary: Headers and libraries for mongo development.
Group: Applications/Databases
%description devel
Mongo (from "huMONGOus") is a schema-free document-oriented database.
This package provides the mongo static library and header files needed
to develop mongo client software.
%prep
%setup
%build
scons --prefix=$RPM_BUILD_ROOT/usr all
# XXX really should have shared library here
%install
scons --prefix=$RPM_BUILD_ROOT/usr install
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
cp debian/*.1 $RPM_BUILD_ROOT/usr/share/man/man1/
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
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/var/lib/mongo
mkdir -p $RPM_BUILD_ROOT/var/log
touch $RPM_BUILD_ROOT/var/log/mongo
%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 || :
%post server
if test $1 = 1
then
/sbin/chkconfig --add mongod
fi
%preun server
if test $1 = 0
then
/sbin/chkconfig --del mongod
fi
%postun server
if test $1 -ge 1
then
/sbin/service mongod stop >/dev/null 2>&1 || :
fi
%files
%defattr(-,root,root,-)
%doc README GNU-AGPL-3.0.txt
%{_bindir}/mongo
%{_bindir}/mongodump
%{_bindir}/mongoexport
%{_bindir}/mongofiles
%{_bindir}/mongoimport
%{_bindir}/mongorestore
%{_mandir}/man1/mongo.1*
%{_mandir}/man1/mongodump.1*
%{_mandir}/man1/mongoexport.1*
%{_mandir}/man1/mongofiles.1*
%{_mandir}/man1/mongoimport.1*
%{_mandir}/man1/mongorestore.1*
%files server
%defattr(-,root,root,-)
%config(noreplace) /etc/mongod.conf
%{_bindir}/mongod
%{_bindir}/mongos
#%{_mandir}/man1/mongod.1*
%{_mandir}/man1/mongos.1*
/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
%files devel
/usr/include/mongo
%{_libdir}/libmongoclient.a
#%{_libdir}/libmongotestfiles.a
%changelog
* Sat Oct 24 2009 Joe Miklojcik <jmiklojcik@shopwiki.com> -
- Wrote mongo.spec.

86
rpm/mongod.conf Normal file
View File

@@ -0,0 +1,86 @@
# mongo.conf
#where to log
logpath=/var/log/mongod
#port = 27017
dbpath=/var/lib/mongo
# Enables periodic logging of CPU utilization and I/O wait
#cpu = true
# Turn on/off security. Off is currently the default
#noauth = true
#auth = true
# Verbose logging output.
#verbose = true
# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true
# Enable db quota management
#quota = true
# Set oplogging level where n is
# 0=off (default)
# 1=W
# 2=R
# 3=both
# 7=W+some reads
#oplog = 0
# Diagnostic/debugging option
#nocursors = true
# Ignore query hints
#nohints = true
# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true
# Turns off server-side scripting. This will result in greatly limited
# functionality
#noscripting = true
# Turns off table scans. Any query that would do a table scan fails.
#notablescan = true
# Disable data file preallocation.
#noprealloc = true
# Specify .ns file size for new databases.
# nssize = <size>
# Accout token for Mongo monitoring server.
#mms-token = <token>
# Server name for Mongo monitoring server.
#mms-name = <server-name>
# Ping interval for Mongo monitoring server.
#mms-interval = <seconds>
# Replication Options
# in replicated mongo databases, specify here whether this is a slave or master
#slave = true
#source = master.example.com
# Slave only: specify a single database to replicate
#only = master.example.com
# or
#master = true
#source = slave.example.com
# Address of a server to pair with.
#pairwith = <server:port>
# Address of arbiter server.
#arbiter = <server:port>
# Automatically resync if slave data is stale
#autoresync
# Custom size for replication operation log.
#oplogSize = <MB>
# Size limit for in-memory storage of op ids.
#opIdMem = <bytes>

View File

@@ -171,7 +171,7 @@ int main(int argc, char* argv[], char *envp[] ) {
return 1;
}
log() << argv[0] << " v0.3- (alpha 3r) starting (--help for usage)" << endl;
log() << argv[0] << " v0.2.6 (alpha 2f) starting (--help for usage)" << endl;
printGitVersion();
printSysInfo();

View File

@@ -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 ))
@@ -818,7 +818,15 @@ namespace mongo {
a = args.obj();
}
BSONObj out = func( a );
BSONObj out;
try {
out = func( a );
}
catch ( std::exception& e ){
JS_ReportError( cx , e.what() );
return JS_FALSE;
}
if ( out.isEmpty() ){
*rval = JSVAL_VOID;

View File

@@ -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 );
@@ -601,3 +601,10 @@ ReplTest.prototype.stop = function( master , signal ){
}
stopMongod( this.getPort( master ) , signal || 15 );
}
allocatePorts = function( n ) {
var ret = [];
for( var i = 31000; i < 31000 + n; ++i )
ret.push( i );
return ret;
}

View File

@@ -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;
@@ -483,7 +447,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 );

View File

@@ -32,6 +32,6 @@
namespace mongo {
const char versionString[] = "1.1.4-";
const char versionString[] = "1.2.4";
} // namespace mongo

View File

@@ -198,13 +198,14 @@ public:
log(1) << "filesize: " << fileSize << endl;
ProgressMeter pm( fileSize );
const int BUF_SIZE = 1024 * 1024 * 4;
char line[ (1024 * 1024 * 4) + 128];
boost::scoped_array<char> line (new char[BUF_SIZE]);
while ( *in ){
in->getline( line , BUF_SIZE );
uassert( "unknown error reading file" , ( in->rdstate() & ios_base::badbit ) == 0 );
log(1) << "got line:" << line << endl;
char * buf = line.get();
in->getline( buf , BUF_SIZE );
uassert( "unknown error reading file" , ( in->rdstate() & ios_base::badbit ) == 0 );
log(1) << "got line:" << buf << endl;
char * buf = line;
while( isspace( buf[0] ) ) buf++;
int len = strlen( buf );

View File

@@ -25,7 +25,7 @@
namespace mongo {
#if !defined(_WIN32) && !defined(NOEXECINFO)
#if !defined(_WIN32) && !defined(NOEXECINFO) && !defined(__freebsd__)
} // namespace mongo
@@ -180,6 +180,7 @@ namespace mongo {
#define localtime _localtime_not_threadsafe_
#define ctime _ctime_is_not_threadsafe_
#if defined(_WIN32) || defined(__sunos__)
inline void sleepsecs(int s) {
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
@@ -208,6 +209,28 @@ namespace mongo {
}
boost::thread::sleep(xt);
}
#else
inline void sleepsecs(int s) {
struct timespec t;
t.tv_sec = s;
t.tv_nsec = 0;
if ( nanosleep( &t , 0 ) ){
cout << "nanosleep failed" << endl;
}
}
inline void sleepmicros(int s) {
struct timespec t;
t.tv_sec = (int)(s / 1000000);
t.tv_nsec = s % 1000000;
if ( nanosleep( &t , 0 ) ){
cout << "nanosleep failed" << endl;
}
}
inline void sleepmillis(int s) {
sleepmicros( s * 1000 );
}
#endif
// note this wraps
inline int tdiff(unsigned told, unsigned tnew) {
return WrappingInt::diff(tnew, told);

View File

@@ -25,6 +25,7 @@
#include "../util/background.h"
#include <fcntl.h>
#include <errno.h>
#include "../db/cmdline.h"
namespace mongo {
@@ -84,7 +85,7 @@ namespace mongo {
continue;
}
disableNagle(s);
log() << "connection accepted from " << from.toString() << " #" << ++connNumber << endl;
if ( ! cmdLine.quiet ) log() << "connection accepted from " << from.toString() << " #" << ++connNumber << endl;
accepted( new MessagingPort(s, from) );
}
}
@@ -295,6 +296,14 @@ again:
}
goto again;
}
if ( len == 542393671 ){
// an http GET
log() << "looks like you're trying to access db over http on native driver port. please add 1000 for webserver" << endl;
static const char * wrongPort = "HTTP 1.0 404 Not Found\nConnection: Close\n\nYou are trying to access MongoDB on the native driver port. For http access, add 1000 to the port\n\n";
::send( sock , wrongPort , strlen( wrongPort ) , 0 );
return false;
}
log() << "bad recv() len: " << len << '\n';
return false;
}

View File

@@ -22,6 +22,10 @@ namespace mongo {
class MemoryMappedFile {
public:
enum Options {
SEQUENTIAL = 1
};
MemoryMappedFile();
~MemoryMappedFile(); /* closes the file if open */
void close();
@@ -32,7 +36,7 @@ namespace mongo {
/* Creates with length if DNE, otherwise uses existing file length,
passed length.
*/
void* map(const char *filename, long &length);
void* map(const char *filename, long &length, int options = 0 );
void flush(bool sync);

View File

@@ -49,7 +49,7 @@ namespace mongo {
#define O_NOATIME 0
#endif
void* MemoryMappedFile::map(const char *filename, long &length) {
void* MemoryMappedFile::map(const char *filename, long &length, int options) {
// length may be updated by callee.
theFileAllocator().allocateAsap( filename, length );
len = length;
@@ -76,9 +76,20 @@ namespace mongo {
}
return 0;
}
#if defined(__sunos__)
#warning madvise not supported on solaris yet
#else
if ( options & SEQUENTIAL ){
if ( madvise( view , length , MADV_SEQUENTIAL ) ){
out() << " madvise failed for " << filename << " " << errno << endl;
}
}
#endif
return view;
}
void MemoryMappedFile::flush(bool sync) {
if ( view == 0 || fd == 0 )
return;

View File

@@ -25,6 +25,7 @@ namespace mongo {
fd = 0;
maphandle = 0;
view = 0;
len = 0;
created();
}
@@ -48,7 +49,7 @@ namespace mongo {
unsigned mapped = 0;
void* MemoryMappedFile::map(const char *_filename, long &length) {
void* MemoryMappedFile::map(const char *_filename, long &length, int options ) {
/* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */
char filename[256];
strncpy(filename, _filename, 255);
@@ -68,9 +69,13 @@ namespace mongo {
updateLength( filename, length );
std::wstring filenamew = toWideString(filename);
DWORD createOptions = FILE_ATTRIBUTE_NORMAL;
if ( options & SEQUENTIAL )
createOptions |= FILE_FLAG_SEQUENTIAL_SCAN;
fd = CreateFile(
filenamew.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
NULL, OPEN_ALWAYS, createOptions , NULL);
if ( fd == INVALID_HANDLE_VALUE ) {
out() << "Create/OpenFile failed " << filename << ' ' << GetLastError() << endl;
return 0;

View File

@@ -21,12 +21,6 @@
#include <iostream>
using namespace std;
#ifdef _WIN32
int getpid(){
return 0;
}
#endif
namespace mongo {
ProcessInfo::ProcessInfo( pid_t pid ){

View File

@@ -0,0 +1,63 @@
// processinfo_win32.cpp
/* Copyright 2009 10gen Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "stdafx.h"
#include "processinfo.h"
#include <iostream>
#include <windows.h>
#include <psapi.h>
using namespace std;
int getpid(){
return GetCurrentProcessId();
}
namespace mongo {
int _wconvertmtos( SIZE_T s ){
return (int)( s / ( 1024 * 1024 ) );
}
ProcessInfo::ProcessInfo( pid_t pid ){
}
ProcessInfo::~ProcessInfo(){
}
bool ProcessInfo::supported(){
return true;
}
int ProcessInfo::getVirtualMemorySize(){
MEMORYSTATUSEX mse;
mse.dwLength = sizeof(mse);
assert( GlobalMemoryStatusEx( &mse ) );
DWORDLONG x = (mse.ullTotalVirtual - mse.ullAvailVirtual) / (1024 * 1024) ;
assert( x <= 0x7fffffff );
return (int) x;
}
int ProcessInfo::getResidentSize(){
PROCESS_MEMORY_COUNTERS pmc;
assert( GetProcessMemoryInfo( GetCurrentProcess() , &pmc, sizeof(pmc) ) );
return _wconvertmtos( pmc.WorkingSetSize );
}
}

View File

@@ -122,9 +122,9 @@ namespace mongo {
#if defined(_WIN32)
(std::cout << now << " " << s).flush();
#else
assert( write( STDOUT_FILENO, now, 20 ) > 0 );
assert( write( STDOUT_FILENO, " ", 1 ) > 0 );
assert( write( STDOUT_FILENO, s.c_str(), s.length() ) > 0 );
write( STDOUT_FILENO, now, 20 );
write( STDOUT_FILENO, " ", 1 );
write( STDOUT_FILENO, s.c_str(), s.length() );
fsync( STDOUT_FILENO );
#endif
}