summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/client/dbclient.cpp32
-rw-r--r--src/mongo/client/dbclient_rs.h4
-rw-r--r--src/mongo/client/dbclientcursor.cpp22
-rw-r--r--src/mongo/client/dbclientinterface.h13
-rw-r--r--src/mongo/client/syncclusterconnection.cpp4
-rw-r--r--src/mongo/client/syncclusterconnection.h1
-rw-r--r--src/mongo/db/db.cpp3
-rw-r--r--src/mongo/db/dbdirectclient.cpp11
-rw-r--r--src/mongo/db/dbdirectclient.h4
-rw-r--r--src/mongo/dbtests/mock/mock_dbclient_connection.cpp4
-rw-r--r--src/mongo/dbtests/mock/mock_dbclient_connection.h1
-rw-r--r--src/mongo/s/server.cpp3
-rw-r--r--src/mongo/util/net/message.h1
-rw-r--r--src/mongo/util/net/message_port.cpp79
-rw-r--r--src/mongo/util/net/message_port.h7
15 files changed, 16 insertions, 173 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp
index bab4ed329f1..91b9562fd99 100644
--- a/src/mongo/client/dbclient.cpp
+++ b/src/mongo/client/dbclient.cpp
@@ -1318,6 +1318,17 @@ void DBClientBase::update(const string& ns, Query query, BSONObj obj, int flags)
say(toSend);
}
+void DBClientBase::killCursor(long long cursorId) {
+ StackBufBuilder b;
+ b.appendNum((int)0); // reserved
+ b.appendNum((int)1); // number
+ b.appendNum(cursorId);
+
+ Message m;
+ m.setData(dbKillCursors, b.buf(), b.len());
+ say(m);
+}
+
list<BSONObj> DBClientWithCommands::getIndexSpecs(const string& ns, int options) {
list<BSONObj> specs;
@@ -1504,10 +1515,6 @@ void DBClientConnection::say(Message& toSend, bool isRetry, string* actualServer
}
}
-void DBClientConnection::sayPiggyBack(Message& toSend) {
- port().piggyBack(toSend);
-}
-
bool DBClientConnection::recv(Message& m) {
if (port().recv(m)) {
return true;
@@ -1580,21 +1587,6 @@ void DBClientConnection::checkResponse(const char* data, int nReturned, bool* re
}
}
-void DBClientConnection::killCursor(long long cursorId) {
- StackBufBuilder b;
- b.appendNum((int)0); // reserved
- b.appendNum((int)1); // number
- b.appendNum(cursorId);
-
- Message m;
- m.setData(dbKillCursors, b.buf(), b.len());
-
- if (_lazyKillCursor)
- sayPiggyBack(m);
- else
- say(m);
-}
-
void DBClientConnection::setParentReplSetName(const string& replSetName) {
_parentReplSetName = replSetName;
}
@@ -1616,8 +1608,6 @@ void DBClientConnection::handleNotMasterResponse(const BSONElement& elemToCheck)
}
AtomicInt32 DBClientConnection::_numConnections;
-bool DBClientConnection::_lazyKillCursor = true;
-
/** @return the database name portion of an ns string */
string nsGetDB(const string& ns) {
diff --git a/src/mongo/client/dbclient_rs.h b/src/mongo/client/dbclient_rs.h
index 203e5eb003d..fd983b5decc 100644
--- a/src/mongo/client/dbclient_rs.h
+++ b/src/mongo/client/dbclient_rs.h
@@ -230,10 +230,6 @@ protected:
*/
virtual void _auth(const BSONObj& params);
- virtual void sayPiggyBack(Message& toSend) {
- checkMaster()->say(toSend);
- }
-
private:
/**
* Used to simplify slave-handling logic on errors
diff --git a/src/mongo/client/dbclientcursor.cpp b/src/mongo/client/dbclientcursor.cpp
index 085cc6f0108..39717721f3c 100644
--- a/src/mongo/client/dbclientcursor.cpp
+++ b/src/mongo/client/dbclientcursor.cpp
@@ -508,30 +508,12 @@ void DBClientCursor::kill() {
DESTRUCTOR_GUARD(
if (cursorId && _ownCursor && !inShutdown()) {
- BufBuilder b;
- b.appendNum((int)0); // reserved
- b.appendNum((int)1); // number
- b.appendNum(cursorId);
-
- Message m;
- m.setData(dbKillCursors, b.buf(), b.len());
-
if (_client) {
- // Kill the cursor the same way the connection itself would. Usually, non-lazily
- if (DBClientConnection::getLazyKillCursor())
- _client->sayPiggyBack(m);
- else
- _client->say(m);
-
+ _client->killCursor(cursorId);
} else {
verify(_scopedHost.size());
ScopedDbConnection conn(_scopedHost);
-
- if (DBClientConnection::getLazyKillCursor())
- conn->sayPiggyBack(m);
- else
- conn->say(m);
-
+ conn->killCursor(cursorId);
conn.done();
}
}
diff --git a/src/mongo/client/dbclientinterface.h b/src/mongo/client/dbclientinterface.h
index 71aa925f832..619e24c206e 100644
--- a/src/mongo/client/dbclientinterface.h
+++ b/src/mongo/client/dbclientinterface.h
@@ -402,7 +402,6 @@ public:
bool assertOk = true,
std::string* actualServer = 0) = 0;
virtual void say(Message& toSend, bool isRetry = false, std::string* actualServer = 0) = 0;
- virtual void sayPiggyBack(Message& toSend) = 0;
/* used by QueryOption_Exhaust. To use that your subclass must implement this. */
virtual bool recv(Message& m) {
verify(false);
@@ -1085,7 +1084,7 @@ public:
*/
virtual bool isStillConnected() = 0;
- virtual void killCursor(long long cursorID) = 0;
+ virtual void killCursor(long long cursorID);
virtual bool callRead(Message& toSend, Message& response) = 0;
@@ -1230,7 +1229,6 @@ public:
return _serverAddress;
}
- virtual void killCursor(long long cursorID);
virtual bool callRead(Message& toSend, Message& response) {
return call(toSend, response);
}
@@ -1266,19 +1264,11 @@ public:
*/
void setParentReplSetName(const std::string& replSetName);
- static void setLazyKillCursor(bool lazy) {
- _lazyKillCursor = lazy;
- }
- static bool getLazyKillCursor() {
- return _lazyKillCursor;
- }
-
uint64_t getSockCreationMicroSec() const;
protected:
friend class SyncClusterConnection;
virtual void _auth(const BSONObj& params);
- virtual void sayPiggyBack(Message& toSend);
std::unique_ptr<MessagingPort> _port;
@@ -1301,7 +1291,6 @@ protected:
double _so_timeout;
static AtomicInt32 _numConnections;
- static bool _lazyKillCursor; // lazy means we piggy back kill cursors on next op
private:
/**
diff --git a/src/mongo/client/syncclusterconnection.cpp b/src/mongo/client/syncclusterconnection.cpp
index 0092262fdbf..a3f5bda6a1d 100644
--- a/src/mongo/client/syncclusterconnection.cpp
+++ b/src/mongo/client/syncclusterconnection.cpp
@@ -580,10 +580,6 @@ void SyncClusterConnection::say(Message& toSend, bool isRetry, string* actualSer
_checkLast();
}
-void SyncClusterConnection::sayPiggyBack(Message& toSend) {
- verify(0);
-}
-
int SyncClusterConnection::_lockType(const string& name) {
{
stdx::lock_guard<stdx::mutex> lk(_mutex);
diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h
index 3ac025aac7c..08a135c2057 100644
--- a/src/mongo/client/syncclusterconnection.h
+++ b/src/mongo/client/syncclusterconnection.h
@@ -107,7 +107,6 @@ public:
virtual bool call(Message& toSend, Message& response, bool assertOk, std::string* actualServer);
virtual void say(Message& toSend, bool isRetry = false, std::string* actualServer = 0);
- virtual void sayPiggyBack(Message& toSend);
virtual void killCursor(long long cursorID);
diff --git a/src/mongo/db/db.cpp b/src/mongo/db/db.cpp
index 5930b728a63..cf5e4721983 100644
--- a/src/mongo/db/db.cpp
+++ b/src/mongo/db/db.cpp
@@ -782,9 +782,6 @@ static int mongoDbMain(int argc, char* argv[], char** envp) {
setupSignalHandlers(false);
- // Mongod shouldn't lazily kill cursors. It doesn't mix well with connection pooling.
- DBClientConnection::setLazyKillCursor(false);
-
dbExecCommand = argv[0];
srand(static_cast<unsigned>(curTimeMicros64()));
diff --git a/src/mongo/db/dbdirectclient.cpp b/src/mongo/db/dbdirectclient.cpp
index 4435547d7c7..244669481c5 100644
--- a/src/mongo/db/dbdirectclient.cpp
+++ b/src/mongo/db/dbdirectclient.cpp
@@ -89,11 +89,6 @@ std::string DBDirectClient::getServerAddress() const {
return "localhost"; // TODO: should this have the port?
}
-void DBDirectClient::sayPiggyBack(Message& toSend) {
- // don't need to piggy back when connected locally
- return say(toSend);
-}
-
bool DBDirectClient::callRead(Message& toSend, Message& response) {
return call(toSend, response);
}
@@ -155,12 +150,6 @@ unique_ptr<DBClientCursor> DBDirectClient::query(const string& ns,
ns, query, nToReturn, nToSkip, fieldsToReturn, queryOptions, batchSize);
}
-void DBDirectClient::killCursor(long long id) {
- // The killCursor command on the DB client is only used by sharding,
- // so no need to have it for MongoD.
- verify(!"killCursor should not be used in MongoD");
-}
-
const HostAndPort DBDirectClient::dummyHost("0.0.0.0", 0);
unsigned long long DBDirectClient::count(
diff --git a/src/mongo/db/dbdirectclient.h b/src/mongo/db/dbdirectclient.h
index d34f1d2379c..a3aa8aaa8db 100644
--- a/src/mongo/db/dbdirectclient.h
+++ b/src/mongo/db/dbdirectclient.h
@@ -81,10 +81,6 @@ public:
virtual void say(Message& toSend, bool isRetry = false, std::string* actualServer = 0);
- virtual void sayPiggyBack(Message& toSend);
-
- virtual void killCursor(long long cursorID);
-
virtual bool callRead(Message& toSend, Message& response);
virtual unsigned long long count(const std::string& ns,
diff --git a/src/mongo/dbtests/mock/mock_dbclient_connection.cpp b/src/mongo/dbtests/mock/mock_dbclient_connection.cpp
index b357b6bf74c..a9af06bd087 100644
--- a/src/mongo/dbtests/mock/mock_dbclient_connection.cpp
+++ b/src/mongo/dbtests/mock/mock_dbclient_connection.cpp
@@ -198,10 +198,6 @@ void MockDBClientConnection::say(mongo::Message& toSend, bool isRetry, string* a
verify(false); // unimplemented
}
-void MockDBClientConnection::sayPiggyBack(mongo::Message& toSend) {
- verify(false); // unimplemented
-}
-
bool MockDBClientConnection::lazySupported() const {
verify(false); // unimplemented
return false;
diff --git a/src/mongo/dbtests/mock/mock_dbclient_connection.h b/src/mongo/dbtests/mock/mock_dbclient_connection.h
index 3572e33b11b..7c05c17e15d 100644
--- a/src/mongo/dbtests/mock/mock_dbclient_connection.h
+++ b/src/mongo/dbtests/mock/mock_dbclient_connection.h
@@ -128,7 +128,6 @@ public:
bool assertOk = true,
std::string* actualServer = 0);
void say(mongo::Message& toSend, bool isRetry = false, std::string* actualServer = 0);
- void sayPiggyBack(mongo::Message& toSend);
bool lazySupported() const;
private:
diff --git a/src/mongo/s/server.cpp b/src/mongo/s/server.cpp
index 4a1653e4fcb..a2c7cec3ff6 100644
--- a/src/mongo/s/server.cpp
+++ b/src/mongo/s/server.cpp
@@ -220,9 +220,6 @@ static ExitCode runMongosServer(bool doUpgrade) {
globalConnPool.addHook(new ShardingConnectionHook(false));
shardConnectionPool.addHook(new ShardingConnectionHook(true));
- // Mongos shouldn't lazily kill cursors, otherwise we can end up with extras from migration
- DBClientConnection::setLazyKillCursor(false);
-
ReplicaSetMonitor::setConfigChangeHook(&ConfigServer::replicaSetChange);
// Mongos connection pools already takes care of authenticating new connections so the
diff --git a/src/mongo/util/net/message.h b/src/mongo/util/net/message.h
index 9aa548ff07b..1a682bc8c3b 100644
--- a/src/mongo/util/net/message.h
+++ b/src/mongo/util/net/message.h
@@ -52,7 +52,6 @@ const size_t MaxMessageSizeBytes = 48 * 1000 * 1000;
class Message;
class MessagingPort;
-class PiggyBackData;
typedef uint32_t MSGID;
diff --git a/src/mongo/util/net/message_port.cpp b/src/mongo/util/net/message_port.cpp
index a14bb1b0580..65eb1f07c0a 100644
--- a/src/mongo/util/net/message_port.cpp
+++ b/src/mongo/util/net/message_port.cpp
@@ -70,46 +70,6 @@ void AbstractMessagingPort::setConnectionId(long long connectionId) {
/* messagingport -------------------------------------------------------------- */
-class PiggyBackData {
-public:
- PiggyBackData(MessagingPort* port) {
- _port = port;
- _buf = new char[1300];
- _cur = _buf;
- }
-
- ~PiggyBackData() {
- DESTRUCTOR_GUARD(flush(); delete[](_cur););
- }
-
- void append(Message& m) {
- verify(m.header().getLen() <= 1300);
-
- if (len() + m.header().getLen() > 1300)
- flush();
-
- memcpy(_cur, m.singleData().view2ptr(), m.header().getLen());
- _cur += m.header().getLen();
- }
-
- void flush() {
- if (_buf == _cur)
- return;
-
- _port->send(_buf, len(), "flush");
- _cur = _buf;
- }
-
- int len() const {
- return _cur - _buf;
- }
-
-private:
- MessagingPort* _port;
- char* _buf;
- char* _cur;
-};
-
class Ports {
std::set<MessagingPort*> ports;
stdx::mutex m;
@@ -142,18 +102,16 @@ void MessagingPort::closeAllSockets(unsigned mask) {
ports.closeAll(mask);
}
-MessagingPort::MessagingPort(int fd, const SockAddr& remote)
- : psock(new Socket(fd, remote)), piggyBackData(0) {
+MessagingPort::MessagingPort(int fd, const SockAddr& remote) : psock(new Socket(fd, remote)) {
ports.insert(this);
}
MessagingPort::MessagingPort(double timeout, logger::LogSeverity ll)
: psock(new Socket(timeout, ll)) {
ports.insert(this);
- piggyBackData = 0;
}
-MessagingPort::MessagingPort(std::shared_ptr<Socket> sock) : psock(sock), piggyBackData(0) {
+MessagingPort::MessagingPort(std::shared_ptr<Socket> sock) : psock(sock) {
ports.insert(this);
}
@@ -166,8 +124,6 @@ void MessagingPort::shutdown() {
}
MessagingPort::~MessagingPort() {
- if (piggyBackData)
- delete (piggyBackData);
shutdown();
ports.erase(this);
}
@@ -294,40 +250,9 @@ void MessagingPort::say(Message& toSend, int responseTo) {
mmm(log() << "* say() thr:" << GetCurrentThreadId() << endl;)
toSend.header().setId(nextMessageId());
toSend.header().setResponseTo(responseTo);
-
- if (piggyBackData && piggyBackData->len()) {
- mmm(log() << "* have piggy back"
- << endl;) if ((piggyBackData->len() + toSend.header().getLen()) > 1300) {
- // won't fit in a packet - so just send it off
- piggyBackData->flush();
- }
- else {
- piggyBackData->append(toSend);
- piggyBackData->flush();
- return;
- }
- }
-
toSend.send(*this, "say");
}
-void MessagingPort::piggyBack(Message& toSend, int responseTo) {
- if (toSend.header().getLen() > 1300) {
- // not worth saving because its almost an entire packet
- say(toSend);
- return;
- }
-
- // we're going to be storing this, so need to set it up
- toSend.header().setId(nextMessageId());
- toSend.header().setResponseTo(responseTo);
-
- if (!piggyBackData)
- piggyBackData = new PiggyBackData(this);
-
- piggyBackData->append(toSend);
-}
-
HostAndPort MessagingPort::remote() const {
if (!_remoteParsed.hasPort()) {
SockAddr sa = psock->remoteAddr();
diff --git a/src/mongo/util/net/message_port.h b/src/mongo/util/net/message_port.h
index 1e1a613438e..e15eb0e7542 100644
--- a/src/mongo/util/net/message_port.h
+++ b/src/mongo/util/net/message_port.h
@@ -39,7 +39,6 @@
namespace mongo {
class MessagingPort;
-class PiggyBackData;
class MessagingPort : public AbstractMessagingPort {
public:
@@ -79,8 +78,6 @@ public:
*/
bool recv(const Message& sent, Message& response);
- void piggyBack(Message& toSend, int responseTo = 0);
-
unsigned remotePort() const {
return psock->remotePort();
}
@@ -121,16 +118,12 @@ public:
}
private:
- PiggyBackData* piggyBackData;
-
// this is the parsed version of remote
// mutable because its initialized only on call to remote()
mutable HostAndPort _remoteParsed;
public:
static void closeAllSockets(unsigned tagMask = 0xffffffff);
-
- friend class PiggyBackData;
};