summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-06-29 09:16:44 -0400
committerAdam Midvidy <amidvidy@gmail.com>2015-06-29 09:27:55 -0400
commita05fe115d44c58b6e81dcd60f254d15cfa3ab243 (patch)
tree121bab8c129785ade5acaf5b700b3ab8c223b413
parent504aadbc372054b7b94cef7a24c1d6b3b5bd867b (diff)
downloadmongo-a05fe115d44c58b6e81dcd60f254d15cfa3ab243.tar.gz
SERVER-19143 remove ns from OpDebug and synchronize access to NS in curop
-rw-r--r--jstests/aggregation/mongos_slaveok.js2
-rw-r--r--jstests/sharding/read_pref_cmd.js2
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp1
-rw-r--r--src/mongo/db/curop.cpp12
-rw-r--r--src/mongo/db/curop.h1
-rw-r--r--src/mongo/db/instance.cpp38
-rw-r--r--src/mongo/db/query/find.cpp2
7 files changed, 30 insertions, 28 deletions
diff --git a/jstests/aggregation/mongos_slaveok.js b/jstests/aggregation/mongos_slaveok.js
index 52790b6f11d..c356a0e7dc5 100644
--- a/jstests/aggregation/mongos_slaveok.js
+++ b/jstests/aggregation/mongos_slaveok.js
@@ -25,7 +25,7 @@ ReplSetTest.awaitRSClientHosts(st.s, secNode, {ok: true });
var res = testDB.runCommand({ aggregate: 'user', pipeline: [{ $project: { x: 1 }}]});
assert(res.ok, 'aggregate command failed: ' + tojson(res));
-var profileQuery = { op: 'command', ns: 'test.$cmd', 'command.aggregate': 'user' };
+var profileQuery = { op: 'command', ns: 'test.user', 'command.aggregate': 'user' };
var profileDoc = secNode.getDB('test').system.profile.findOne(profileQuery);
assert(profileDoc != null);
diff --git a/jstests/sharding/read_pref_cmd.js b/jstests/sharding/read_pref_cmd.js
index e5c0585faa2..03b8991fa1a 100644
--- a/jstests/sharding/read_pref_cmd.js
+++ b/jstests/sharding/read_pref_cmd.js
@@ -60,7 +60,7 @@ var testReadPreference = function(conn, hostList, isMongos, mode, tagSets, secEx
assert(cmdResult.ok);
var testedAtLeastOnce = false;
- var query = { op: 'command', ns: 'test.$cmd' };
+ var query = { op: 'command' };
Object.extend(query, profileQuery);
hostList.forEach(function(node) {
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 0087f7b77f4..ae7c702caec 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -483,7 +483,6 @@ static void beginCurrentOp(OperationContext* txn, const BatchItemRef& currWrite)
currentOp->ensureStarted();
currentOp->setNS_inlock(currWrite.getRequest()->getNS());
- currentOp->debug().ns = currentOp->getNS();
currentOp->debug().op = currentOp->getOp();
if (currWrite.getOpType() == BatchedCommandRequest::BatchType_Insert) {
diff --git a/src/mongo/db/curop.cpp b/src/mongo/db/curop.cpp
index 335d2107fa9..818a516ba9e 100644
--- a/src/mongo/db/curop.cpp
+++ b/src/mongo/db/curop.cpp
@@ -233,11 +233,7 @@ void CurOp::reportState(BSONObjBuilder* builder) {
builder->append("op", opToString(_op));
- // Fill out "ns" from our namespace member (and if it's not available, fall back to the
- // OpDebug namespace member). We prefer our ns when set because it changes to match each
- // accessed namespace, while _debug.ns is set once at the start of the operation. However,
- // sometimes _ns is not yet set.
- builder->append("ns", !_ns.empty() ? _ns : _debug.ns);
+ builder->append("ns", _ns);
if (_op == dbInsert) {
_query.append(*builder, "insert");
@@ -375,7 +371,6 @@ uint64_t CurOp::MaxTimeTracker::getRemainingMicros() const {
void OpDebug::reset() {
op = 0;
iscommand = false;
- ns = "";
query = BSONObj();
updateobj = BSONObj();
@@ -432,7 +427,8 @@ string OpDebug::report(const CurOp& curop, const SingleThreadedLockStats& lockSt
s << "command ";
else
s << opToString(op) << ' ';
- s << ns;
+
+ s << curop.getNS();
if (!query.isEmpty()) {
if (iscommand) {
@@ -556,7 +552,7 @@ void OpDebug::append(const CurOp& curop,
const size_t maxElementSize = 50 * 1024;
b.append("op", iscommand ? "command" : opToString(op));
- b.append("ns", ns);
+ b.append("ns", curop.getNS());
if (!query.isEmpty()) {
appendAsObjOrString(iscommand ? "command" : "query", query, maxElementSize, &b);
diff --git a/src/mongo/db/curop.h b/src/mongo/db/curop.h
index 42404c30533..aa7a25dd610 100644
--- a/src/mongo/db/curop.h
+++ b/src/mongo/db/curop.h
@@ -151,7 +151,6 @@ public:
// basic options
int op;
bool iscommand;
- std::string ns;
BSONObj query;
BSONObj updateobj;
diff --git a/src/mongo/db/instance.cpp b/src/mongo/db/instance.cpp
index 14936651d40..257193b53c9 100644
--- a/src/mongo/db/instance.cpp
+++ b/src/mongo/db/instance.cpp
@@ -634,7 +634,6 @@ void receivedKillCursors(OperationContext* txn, Message& m) {
void receivedUpdate(OperationContext* txn, const NamespaceString& nsString, Message& m, CurOp& op) {
DbMessage d(m);
uassertStatusOK(userAllowedWriteNS(nsString));
- op.debug().ns = nsString.ns();
int flags = d.pullInt();
BSONObj query = d.nextJsObj();
@@ -648,18 +647,19 @@ void receivedUpdate(OperationContext* txn, const NamespaceString& nsString, Mess
bool multi = flags & UpdateOption_Multi;
bool broadcast = flags & UpdateOption_Broadcast;
- Status status = AuthorizationSession::get(txn->getClient())
- ->checkAuthForUpdate(nsString, query, toupdate, upsert);
- audit::logUpdateAuthzCheck(
- txn->getClient(), nsString, query, toupdate, upsert, multi, status.code());
- uassertStatusOK(status);
-
op.debug().query = query;
{
stdx::lock_guard<Client> lk(*txn->getClient());
+ op.setNS_inlock(nsString.ns());
op.setQuery_inlock(query);
}
+ Status status = AuthorizationSession::get(txn->getClient())
+ ->checkAuthForUpdate(nsString, query, toupdate, upsert);
+ audit::logUpdateAuthzCheck(
+ txn->getClient(), nsString, query, toupdate, upsert, multi, status.code());
+ uassertStatusOK(status);
+
UpdateRequest request(nsString);
request.setUpsert(upsert);
request.setMulti(multi);
@@ -752,23 +752,23 @@ void receivedDelete(OperationContext* txn, const NamespaceString& nsString, Mess
DbMessage d(m);
uassertStatusOK(userAllowedWriteNS(nsString));
- op.debug().ns = nsString.ns();
int flags = d.pullInt();
bool justOne = flags & RemoveOption_JustOne;
verify(d.moreJSObjs());
BSONObj pattern = d.nextJsObj();
- Status status =
- AuthorizationSession::get(txn->getClient())->checkAuthForDelete(nsString, pattern);
- audit::logDeleteAuthzCheck(txn->getClient(), nsString, pattern, status.code());
- uassertStatusOK(status);
-
op.debug().query = pattern;
{
stdx::lock_guard<Client> lk(*txn->getClient());
op.setQuery_inlock(pattern);
+ op.setNS_inlock(nsString.ns());
}
+ Status status =
+ AuthorizationSession::get(txn->getClient())->checkAuthForDelete(nsString, pattern);
+ audit::logDeleteAuthzCheck(txn->getClient(), nsString, pattern, status.code());
+ uassertStatusOK(status);
+
DeleteRequest request(nsString);
request.setQuery(pattern);
request.setMulti(!justOne);
@@ -819,10 +819,14 @@ bool receivedGetMore(OperationContext* txn, DbResponse& dbresponse, Message& m,
int ntoreturn = d.pullInt();
long long cursorid = d.pullInt64();
- curop.debug().ns = ns;
curop.debug().ntoreturn = ntoreturn;
curop.debug().cursorid = cursorid;
+ {
+ stdx::lock_guard<Client>(*txn->getClient());
+ CurOp::get(txn)->setNS_inlock(ns);
+ }
+
unique_ptr<AssertionException> ex;
unique_ptr<Timer> timer;
int pass = 0;
@@ -1059,7 +1063,11 @@ static void insertSystemIndexes(OperationContext* txn, DbMessage& d, CurOp& curO
void receivedInsert(OperationContext* txn, const NamespaceString& nsString, Message& m, CurOp& op) {
DbMessage d(m);
const char* ns = d.getns();
- op.debug().ns = ns;
+ {
+ stdx::lock_guard<Client>(*txn->getClient());
+ CurOp::get(txn)->setNS_inlock(nsString.ns());
+ }
+
uassertStatusOK(userAllowedWriteNS(nsString.ns()));
if (nsString.isSystemDotIndexes()) {
insertSystemIndexes(txn, d, op);
diff --git a/src/mongo/db/query/find.cpp b/src/mongo/db/query/find.cpp
index 33b95a1cf77..72fc8d6a294 100644
--- a/src/mongo/db/query/find.cpp
+++ b/src/mongo/db/query/find.cpp
@@ -181,12 +181,12 @@ void beginQueryOp(OperationContext* txn,
int ntoreturn,
int ntoskip) {
auto curop = CurOp::get(txn);
- curop->debug().ns = nss.ns();
curop->debug().query = queryObj;
curop->debug().ntoreturn = ntoreturn;
curop->debug().ntoskip = ntoskip;
stdx::lock_guard<Client> lk(*txn->getClient());
curop->setQuery_inlock(queryObj);
+ curop->setNS_inlock(nss.ns());
}
void endQueryOp(OperationContext* txn,