summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2013-03-26 16:54:49 -0400
committerGreg Studer <greg@10gen.com>2013-03-29 10:33:56 -0400
commitbca711f26fc6a76220fb420f5fe83cad7384f423 (patch)
tree050a6b458e27105c73c03534645e979b00570317
parent9412afa6f3a61f173f8a43ed9af5d45164dda818 (diff)
downloadmongo-bca711f26fc6a76220fb420f5fe83cad7384f423.tar.gz
SERVER-9139 clean up unsharded cursors in CursorCache
-rw-r--r--src/mongo/s/cursors.cpp7
-rw-r--r--src/mongo/s/cursors.h1
-rw-r--r--src/mongo/s/strategy_shard.cpp8
3 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/s/cursors.cpp b/src/mongo/s/cursors.cpp
index affb7f744fd..4e904e39c4c 100644
--- a/src/mongo/s/cursors.cpp
+++ b/src/mongo/s/cursors.cpp
@@ -203,6 +203,13 @@ namespace mongo {
_cursors.erase( id );
}
+ void CursorCache::removeRef( long long id ) {
+ verify( id );
+ scoped_lock lk( _mutex );
+ _refs.erase( id );
+ _refsNS.erase( id );
+ }
+
void CursorCache::storeRef(const std::string& server, long long id, const std::string& ns) {
LOG(_myLogLevel) << "CursorCache::storeRef server: " << server << " id: " << id << endl;
verify( id );
diff --git a/src/mongo/s/cursors.h b/src/mongo/s/cursors.h
index b42ea7538d7..c250d70ded2 100644
--- a/src/mongo/s/cursors.h
+++ b/src/mongo/s/cursors.h
@@ -105,6 +105,7 @@ namespace mongo {
void remove( long long id );
void storeRef(const std::string& server, long long id, const std::string& ns);
+ void removeRef( long long id );
/** @return the server for id or "" */
string getRef( long long id ) const ;
diff --git a/src/mongo/s/strategy_shard.cpp b/src/mongo/s/strategy_shard.cpp
index 2f8667de6d8..0d4adcef155 100644
--- a/src/mongo/s/strategy_shard.cpp
+++ b/src/mongo/s/strategy_shard.cpp
@@ -212,8 +212,14 @@ namespace mongo {
Message response;
bool ok = conn->get()->callRead( r.m() , response);
uassert( 10204 , "dbgrid: getmore: error calling db", ok);
- r.reply( response , "" /*conn->getServerAddress() */ );
+ bool hasMore = (response.singleData()->getCursor() != 0);
+
+ if ( !hasMore ) {
+ cursorCache.removeRef( id );
+ }
+
+ r.reply( response , "" /*conn->getServerAddress() */ );
conn->done();
return;
}