Skip to content

Commit

Permalink
SERVER-8188: make cursor timeout configurable on server
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Mar 13, 2015
1 parent ae97946 commit 4d7b131
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/mongo/bson/bsonelement.cpp
Expand Up @@ -746,6 +746,13 @@ namespace mongo {
return true;
}

template<> bool BSONElement::coerce<long long>( long long* out ) const {
if ( !isNumber() )
return false;
*out = numberLong();
return true;
}

template<> bool BSONElement::coerce<double>( double* out ) const {
if ( !isNumber() )
return false;
Expand Down
5 changes: 4 additions & 1 deletion src/mongo/db/clientcursor.cpp
Expand Up @@ -48,6 +48,7 @@
#include "mongo/db/jsobj.h"
#include "mongo/db/operation_context_impl.h"
#include "mongo/db/repl/replication_coordinator_global.h"
#include "mongo/db/server_parameters.h"
#include "mongo/util/exit.h"

namespace mongo {
Expand All @@ -69,6 +70,8 @@ namespace mongo {
static ServerStatusMetricField<Counter64> dCursorStatusTimedout( "cursor.timedOut",
&cursorStatsTimedOut );

MONGO_EXPORT_SERVER_PARAMETER(cursorTimeoutMillis, int, 10 * 60 * 1000 /* 10 minutes */);

long long ClientCursor::totalOpen() {
return cursorStatsOpen.get();
}
Expand Down Expand Up @@ -171,7 +174,7 @@ namespace mongo {
if (_isNoTimeout || _isPinned) {
return false;
}
return _idleAgeMillis > 600000;
return _idleAgeMillis > cursorTimeoutMillis;
}

void ClientCursor::setIdleTime( int millis ) {
Expand Down
7 changes: 6 additions & 1 deletion src/mongo/s/cursors.cpp
Expand Up @@ -47,6 +47,7 @@
#include "mongo/db/commands.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/max_time.h"
#include "mongo/db/server_parameters.h"
#include "mongo/util/concurrency/task.h"
#include "mongo/util/log.h"
#include "mongo/util/net/listen.h"
Expand Down Expand Up @@ -218,7 +219,11 @@ namespace mongo {

// ---- CursorCache -----

long long CursorCache::TIMEOUT = 600000;
long long CursorCache::TIMEOUT = 10 * 60 * 1000 /* 10 minutes */;
ExportedServerParameter<long long> cursorCacheTimeoutConfig(ServerParameterSet::getGlobal(),
"cursorTimeoutMillis",
&CursorCache::TIMEOUT,
true, true);

unsigned getCCRandomSeed() {
scoped_ptr<SecureRandom> sr( SecureRandom::create() );
Expand Down

0 comments on commit 4d7b131

Please sign in to comment.