mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Revert "Throttle sharding requests when processing WriteBacks"
This reverts commit 2e41c3387c
.
This commit is contained in:
parent
2e41c3387c
commit
c226367562
@ -27,30 +27,9 @@
|
|||||||
|
|
||||||
namespace mongo {
|
namespace mongo {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
mutex sleepMutex ("WriteBackThrottle");
|
|
||||||
int sleepTime (10);
|
|
||||||
Date_t throttleUntil(0);
|
|
||||||
thread_specific_ptr<int> writeBackThreadMarker; // non-NULL if in writeBack thread
|
|
||||||
|
|
||||||
void throttleIfNeeded() {
|
|
||||||
if (!writeBackThreadMarker.get() && jsTime() < throttleUntil){
|
|
||||||
int i;
|
|
||||||
{
|
|
||||||
scoped_lock lock (sleepMutex);
|
|
||||||
i = sleepTime++;
|
|
||||||
}
|
|
||||||
sleepmillis(min(1000, sleepTime));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----- Strategy ------
|
// ----- Strategy ------
|
||||||
|
|
||||||
void Strategy::doWrite( int op , Request& r , const Shard& shard , bool checkVersion ){
|
void Strategy::doWrite( int op , Request& r , const Shard& shard , bool checkVersion ){
|
||||||
throttleIfNeeded();
|
|
||||||
|
|
||||||
ShardConnection conn( shard , r.getns() );
|
ShardConnection conn( shard , r.getns() );
|
||||||
if ( ! checkVersion )
|
if ( ! checkVersion )
|
||||||
conn.donotCheckVersion();
|
conn.donotCheckVersion();
|
||||||
@ -91,8 +70,6 @@ namespace mongo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Strategy::insert( const Shard& shard , const char * ns , const BSONObj& obj ){
|
void Strategy::insert( const Shard& shard , const char * ns , const BSONObj& obj ){
|
||||||
throttleIfNeeded();
|
|
||||||
|
|
||||||
ShardConnection dbcon( shard , ns );
|
ShardConnection dbcon( shard , ns );
|
||||||
if ( dbcon.setVersion() ){
|
if ( dbcon.setVersion() ){
|
||||||
dbcon.done();
|
dbcon.done();
|
||||||
@ -110,9 +87,6 @@ namespace mongo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void run(){
|
void run(){
|
||||||
// doesn't matter what is put in here, just that it is not NULL
|
|
||||||
writeBackThreadMarker.reset(new int());
|
|
||||||
|
|
||||||
OID lastID;
|
OID lastID;
|
||||||
lastID.clear();
|
lastID.clear();
|
||||||
int secsToSleep = 0;
|
int secsToSleep = 0;
|
||||||
@ -141,8 +115,6 @@ namespace mongo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log(1) << "writebacklisten result: " << result << endl;
|
log(1) << "writebacklisten result: " << result << endl;
|
||||||
|
|
||||||
throttleUntil = jsTime() + 1000;
|
|
||||||
|
|
||||||
BSONObj data = result.getObjectField( "data" );
|
BSONObj data = result.getObjectField( "data" );
|
||||||
if ( data.getBoolField( "writeBack" ) ){
|
if ( data.getBoolField( "writeBack" ) ){
|
||||||
@ -182,11 +154,6 @@ namespace mongo {
|
|||||||
log() << "unknown writeBack result: " << result << endl;
|
log() << "unknown writeBack result: " << result << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OCCASIONALLY {
|
|
||||||
scoped_lock lock (sleepMutex);
|
|
||||||
sleepTime /= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
conn.done();
|
conn.done();
|
||||||
secsToSleep = 0;
|
secsToSleep = 0;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user