mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
concurrency work
This commit is contained in:
parent
dddad48519
commit
0877fc6c93
@ -388,7 +388,7 @@ if has_option( "asio" ):
|
||||
coreServerFiles += [ "util/net/message_server_asio.cpp" ]
|
||||
|
||||
# mongod files - also files used in tools. present in dbtests, but not in mongos and not in client libs.
|
||||
serverOnlyFiles = Split( "util/compress.cpp db/key.cpp db/btreebuilder.cpp util/logfile.cpp util/alignedbuilder.cpp db/mongommf.cpp db/dur.cpp db/durop.cpp db/dur_writetodatafiles.cpp db/dur_preplogbuffer.cpp db/dur_commitjob.cpp db/dur_recover.cpp db/dur_journal.cpp db/introspect.cpp db/btree.cpp db/clientcursor.cpp db/tests.cpp db/repl.cpp db/repl/rs.cpp db/repl/consensus.cpp db/repl/rs_initiate.cpp db/repl/replset_commands.cpp db/repl/manager.cpp db/repl/health.cpp db/repl/heartbeat.cpp db/repl/rs_config.cpp db/repl/rs_rollback.cpp db/repl/rs_sync.cpp db/repl/rs_initialsync.cpp db/oplog.cpp db/repl_block.cpp db/btreecursor.cpp db/cloner.cpp db/namespace.cpp db/cap.cpp db/matcher_covered.cpp db/dbeval.cpp db/restapi.cpp db/dbhelpers.cpp db/instance.cpp db/client.cpp db/database.cpp db/pdfile.cpp db/record.cpp db/cursor.cpp db/security.cpp db/queryoptimizer.cpp db/queryoptimizercursor.cpp db/extsort.cpp db/cmdline.cpp" )
|
||||
serverOnlyFiles = Split( "util/compress.cpp db/d_concurrency.cpp db/key.cpp db/btreebuilder.cpp util/logfile.cpp util/alignedbuilder.cpp db/mongommf.cpp db/dur.cpp db/durop.cpp db/dur_writetodatafiles.cpp db/dur_preplogbuffer.cpp db/dur_commitjob.cpp db/dur_recover.cpp db/dur_journal.cpp db/introspect.cpp db/btree.cpp db/clientcursor.cpp db/tests.cpp db/repl.cpp db/repl/rs.cpp db/repl/consensus.cpp db/repl/rs_initiate.cpp db/repl/replset_commands.cpp db/repl/manager.cpp db/repl/health.cpp db/repl/heartbeat.cpp db/repl/rs_config.cpp db/repl/rs_rollback.cpp db/repl/rs_sync.cpp db/repl/rs_initialsync.cpp db/oplog.cpp db/repl_block.cpp db/btreecursor.cpp db/cloner.cpp db/namespace.cpp db/cap.cpp db/matcher_covered.cpp db/dbeval.cpp db/restapi.cpp db/dbhelpers.cpp db/instance.cpp db/client.cpp db/database.cpp db/pdfile.cpp db/record.cpp db/cursor.cpp db/security.cpp db/queryoptimizer.cpp db/queryoptimizercursor.cpp db/extsort.cpp db/cmdline.cpp" )
|
||||
|
||||
serverOnlyFiles += [ "db/index.cpp" , "db/scanandorder.cpp" ] + Glob( "db/geo/*.cpp" ) + Glob( "db/ops/*.cpp" )
|
||||
|
||||
|
@ -141,8 +141,6 @@ namespace mongo {
|
||||
*/
|
||||
bool sometimes(unsigned howOften) { return ++_sometimes % howOften == 0; }
|
||||
|
||||
public:
|
||||
|
||||
/* set _god=true temporarily, safely */
|
||||
class GodScope {
|
||||
bool _prev;
|
||||
@ -221,9 +219,14 @@ namespace mongo {
|
||||
|
||||
string _ns;
|
||||
Database * _db;
|
||||
|
||||
}; // class Client::Context
|
||||
|
||||
struct LockStatus {
|
||||
LockStatus() : db(), coll() { }
|
||||
int db;
|
||||
int coll;
|
||||
} lockStatus;
|
||||
|
||||
}; // class Client
|
||||
|
||||
/** get the Client object for this thread. */
|
||||
|
17
db/d_concurrency.cpp
Normal file
17
db/d_concurrency.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "../pch.h"
|
||||
#include "database.h"
|
||||
#include "d_concurrency.h"
|
||||
#include "../util/concurrency/threadlocal.h"
|
||||
#include "../util/concurrency/rwlock.h"
|
||||
#include "client.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace mongo {
|
||||
|
||||
LockCollectionForReading::LockCollectionForReading(const char *ns)
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
}
|
38
db/d_concurrency.h
Normal file
38
db/d_concurrency.h
Normal file
@ -0,0 +1,38 @@
|
||||
// @file d_concurrency.h
|
||||
|
||||
#pragma once
|
||||
|
||||
//#include "mongomutex.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
/* these may be used recursively as long as you do not
|
||||
try to go from sharable to exclusive
|
||||
*/
|
||||
|
||||
//void assertDbLocked();
|
||||
//void assertCollectionLocked();
|
||||
|
||||
/*class LockDatabaseExclusively : boost::noncopyable {
|
||||
public:
|
||||
LockDatabaseExclusively(const char *db);
|
||||
};*/
|
||||
|
||||
/*class LockCollectionUpgradably : boost::noncopyable {
|
||||
public:
|
||||
LockCollectionUpgradably(const char *ns);
|
||||
};*/
|
||||
|
||||
class LockCollectionForReading : boost::noncopyable {
|
||||
Database *db;
|
||||
public:
|
||||
LockCollectionForReading(const char *ns);
|
||||
~LockCollectionForReading();
|
||||
};
|
||||
|
||||
class LockCollectionExclusively : boost::noncopyable {
|
||||
public:
|
||||
LockCollectionExclusively(const char *ns);
|
||||
};
|
||||
|
||||
}
|
@ -19,9 +19,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "cmdline.h"
|
||||
#include "namespace.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
class Extent;
|
||||
class MongoDataFile;
|
||||
class ClientCursor;
|
||||
struct ByLocKey;
|
||||
typedef map<ByLocKey, ClientCursor*> CCByLoc;
|
||||
@ -126,6 +129,8 @@ namespace mongo {
|
||||
const string profileName; // "alleyinsider.system.profile"
|
||||
CCByLoc ccByLoc;
|
||||
int magic; // used for making sure the object is still loaded in memory
|
||||
|
||||
RWLockBase dbLock; // d_concurrency.h
|
||||
};
|
||||
|
||||
} // namespace mongo
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "ops/update.h"
|
||||
#include "ops/delete.h"
|
||||
#include "ops/query.h"
|
||||
#include "d_concurrency.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
@ -473,7 +474,8 @@ namespace mongo {
|
||||
|
||||
writelock lk;
|
||||
|
||||
// writelock is used to synchronize stepdowns w/ writes
|
||||
// void ReplSetImpl::relinquish() uses big write lock so
|
||||
// this is thus synchronized given our lock above.
|
||||
uassert( 10054 , "not master", isMasterNs( ns ) );
|
||||
|
||||
// if this ever moves to outside of lock, need to adjust check Client::Context::_finishInit
|
||||
@ -666,7 +668,9 @@ namespace mongo {
|
||||
}
|
||||
|
||||
writelock lk(ns);
|
||||
//LockCollectionExclusively lk(ns);
|
||||
|
||||
// CONCURRENCY TODO: is being read locked in big log sufficient here?
|
||||
// writelock is used to synchronize stepdowns w/ writes
|
||||
uassert( 10058 , "not master", isMasterNs(ns) );
|
||||
|
||||
|
1472
dbtests/test.vcxproj
1472
dbtests/test.vcxproj
File diff suppressed because it is too large
Load Diff
@ -893,6 +893,9 @@
|
||||
<ClCompile Include="..\db\commands\cloud.cpp">
|
||||
<Filter>db\cpp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\db\d_concurrency.cpp">
|
||||
<Filter>db\cpp</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\SConstruct">
|
||||
|
Loading…
Reference in New Issue
Block a user