mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
revert tracking stack of current ops, as not enough infrastructure in place to handle all cases well
This commit is contained in:
parent
f79e2e6b15
commit
13f2cc026f
141
db/curop.h
141
db/curop.h
@ -1,72 +1,69 @@
|
||||
// curop.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "namespace.h"
|
||||
#include "security.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
struct CurOp {
|
||||
void reset(time_t now) {
|
||||
active = true;
|
||||
opNum++;
|
||||
startTime = now;
|
||||
ns[0] = '?'; // just in case not set later
|
||||
*query = 0;
|
||||
killCurrentOp = 0;
|
||||
}
|
||||
|
||||
bool active;
|
||||
unsigned opNum;
|
||||
time_t startTime;
|
||||
int op;
|
||||
char ns[Namespace::MaxNsLen+1];
|
||||
char query[128];
|
||||
char zero;
|
||||
|
||||
CurOp() {
|
||||
opNum = 0;
|
||||
ns[sizeof(ns)-1] = 0;
|
||||
query[sizeof(query)-1] = 0;
|
||||
}
|
||||
|
||||
BSONObj info() {
|
||||
AuthenticationInfo *ai = authInfo.get();
|
||||
if( ai == 0 || !ai->isAuthorized("admin") ) {
|
||||
BSONObjBuilder b;
|
||||
b.append("err", "unauthorized");
|
||||
return b.obj();
|
||||
}
|
||||
return infoNoauth();
|
||||
}
|
||||
|
||||
BSONObj infoNoauth() const {
|
||||
BSONObjBuilder b;
|
||||
b.append("opid", opNum);
|
||||
b.append("active", active);
|
||||
if( active )
|
||||
b.append("secs_running", (int) (time(0)-startTime));
|
||||
if( op == 2004 )
|
||||
b.append("op", "query");
|
||||
else if( op == 2005 )
|
||||
b.append("op", "getMore");
|
||||
else if( op == 2001 )
|
||||
b.append("op", "update");
|
||||
else if( op == 2002 )
|
||||
b.append("op", "insert");
|
||||
else if( op == 2006 )
|
||||
b.append("op", "delete");
|
||||
else
|
||||
b.append("op", op);
|
||||
b.append("ns", ns);
|
||||
b.append("query", query);
|
||||
b.append("inLock", dbMutexInfo.isLocked());
|
||||
return b.obj();
|
||||
}
|
||||
};
|
||||
|
||||
CurOp ¤tOp();
|
||||
void pushCurrentOp();
|
||||
void popCurrentOp();
|
||||
}
|
||||
// curop.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "namespace.h"
|
||||
#include "security.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
extern struct CurOp {
|
||||
void reset(time_t now) {
|
||||
active = true;
|
||||
opNum++;
|
||||
startTime = now;
|
||||
ns[0] = '?'; // just in case not set later
|
||||
*query = 0;
|
||||
killCurrentOp = 0;
|
||||
}
|
||||
|
||||
bool active;
|
||||
unsigned opNum;
|
||||
time_t startTime;
|
||||
int op;
|
||||
char ns[Namespace::MaxNsLen+1];
|
||||
char query[128];
|
||||
char zero;
|
||||
|
||||
CurOp() {
|
||||
opNum = 0;
|
||||
ns[sizeof(ns)-1] = 0;
|
||||
query[sizeof(query)-1] = 0;
|
||||
}
|
||||
|
||||
BSONObj info() {
|
||||
AuthenticationInfo *ai = authInfo.get();
|
||||
if( ai == 0 || !ai->isAuthorized("admin") ) {
|
||||
BSONObjBuilder b;
|
||||
b.append("err", "unauthorized");
|
||||
return b.obj();
|
||||
}
|
||||
return infoNoauth();
|
||||
}
|
||||
|
||||
BSONObj infoNoauth() {
|
||||
BSONObjBuilder b;
|
||||
b.append("opid", opNum);
|
||||
b.append("active", active);
|
||||
if( active )
|
||||
b.append("secs_running", (int) (time(0)-startTime));
|
||||
if( op == 2004 )
|
||||
b.append("op", "query");
|
||||
else if( op == 2005 )
|
||||
b.append("op", "getMore");
|
||||
else if( op == 2001 )
|
||||
b.append("op", "update");
|
||||
else if( op == 2002 )
|
||||
b.append("op", "insert");
|
||||
else if( op == 2006 )
|
||||
b.append("op", "delete");
|
||||
else
|
||||
b.append("op", op);
|
||||
b.append("ns", ns);
|
||||
b.append("query", query);
|
||||
b.append("inLock", dbMutexInfo.isLocked());
|
||||
return b.obj();
|
||||
}
|
||||
} currentOp;
|
||||
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ namespace mongo {
|
||||
rawOut( ossSig.str() );
|
||||
|
||||
ostringstream ossOp;
|
||||
ossOp << "Last op: " << currentOp().infoNoauth() << endl;
|
||||
ossOp << "Last op: " << currentOp.infoNoauth() << endl;
|
||||
rawOut( ossOp.str() );
|
||||
|
||||
ostringstream oss;
|
||||
|
@ -113,9 +113,7 @@ namespace mongo {
|
||||
public:
|
||||
// caller locks
|
||||
void doLockedStuff(stringstream& ss) {
|
||||
ss << "current ops: \n";
|
||||
for( vector< CurOp >::const_iterator i = currentOpsBegin(); i != currentOpsEnd(); ++i )
|
||||
ss << "\t" << i->infoNoauth() << "\n";
|
||||
ss << "currentOp: " << currentOp.infoNoauth() << "\n";
|
||||
ss << "# databases: " << databases.size() << '\n';
|
||||
if ( database ) {
|
||||
ss << "curclient: " << database->name;
|
||||
|
@ -90,16 +90,10 @@ namespace mongo {
|
||||
|
||||
int lockFile = 0;
|
||||
|
||||
vector< CurOp > currentOps;
|
||||
CurOp ¤tOp() { return currentOps.back(); }
|
||||
bool haveCurrentOp() { return !currentOps.empty(); }
|
||||
void pushCurrentOp() { currentOps.push_back( CurOp() ); }
|
||||
void popCurrentOp() { currentOps.pop_back(); }
|
||||
vector< CurOp >::const_iterator currentOpsBegin() { return currentOps.begin(); }
|
||||
vector< CurOp >::const_iterator currentOpsEnd() { return currentOps.end(); }
|
||||
CurOp currentOp;
|
||||
|
||||
void inProgCmd( Message &m, DbResponse &dbresponse ) {
|
||||
BSONObj obj = currentOp().info();
|
||||
BSONObj obj = currentOp.info();
|
||||
replyToQuery(0, m, dbresponse, obj);
|
||||
}
|
||||
|
||||
@ -146,11 +140,8 @@ namespace mongo {
|
||||
|
||||
stringstream ss;
|
||||
char buf[64];
|
||||
while ( haveCurrentOp() && !currentOp().active )
|
||||
popCurrentOp();
|
||||
pushCurrentOp();
|
||||
time_t now = time(0);
|
||||
currentOp().reset(now);
|
||||
currentOp.reset(now);
|
||||
|
||||
time_t_to_String(now, buf);
|
||||
buf[20] = 0; // don't want the year
|
||||
@ -161,7 +152,7 @@ namespace mongo {
|
||||
|
||||
int ms;
|
||||
bool log = false;
|
||||
currentOp().op = curOp = m.data->operation();
|
||||
currentOp.op = curOp = m.data->operation();
|
||||
|
||||
#if 0
|
||||
/* use this if you only want to process operations for a particular namespace.
|
||||
@ -208,7 +199,7 @@ namespace mongo {
|
||||
const char *ns = m.data->_data + 4;
|
||||
char cl[256];
|
||||
nsToClient(ns, cl);
|
||||
strncpy(currentOp().ns, ns, Namespace::MaxNsLen);
|
||||
strncpy(currentOp.ns, ns, Namespace::MaxNsLen);
|
||||
AuthenticationInfo *ai = authInfo.get();
|
||||
if( !ai->isAuthorized(cl) ) {
|
||||
uassert_nothrow("unauthorized");
|
||||
@ -260,7 +251,7 @@ namespace mongo {
|
||||
}
|
||||
else {
|
||||
out() << " operation isn't supported: " << m.data->operation() << endl;
|
||||
currentOp().active = false;
|
||||
currentOp.active = false;
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
@ -278,7 +269,7 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
|
||||
currentOp().active = false;
|
||||
currentOp.active = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -339,7 +330,7 @@ namespace mongo {
|
||||
{
|
||||
string s = query.toString();
|
||||
ss << " query: " << s;
|
||||
strncpy(currentOp().query, s.c_str(), sizeof(currentOp().query)-1);
|
||||
strncpy(currentOp.query, s.c_str(), sizeof(currentOp.query)-1);
|
||||
}
|
||||
bool updatedExisting = updateObjects(ns, toupdate, query, flags & 1, ss);
|
||||
recordUpdate( updatedExisting, ( upsert || updatedExisting ) ? 1 : 0 );
|
||||
@ -358,7 +349,7 @@ namespace mongo {
|
||||
{
|
||||
string s = pattern.toString();
|
||||
ss << " query: " << s;
|
||||
strncpy(currentOp().query, s.c_str(), sizeof(currentOp().query)-1);
|
||||
strncpy(currentOp.query, s.c_str(), sizeof(currentOp.query)-1);
|
||||
}
|
||||
int n = deleteObjects(ns, pattern, justOne, true);
|
||||
recordDelete( n );
|
||||
@ -387,7 +378,7 @@ namespace mongo {
|
||||
uassert( "not master", isMasterNs( q.ns ) || (q.queryOptions & Option_SlaveOk) || strstr( q.ns, ".$cmd" ) );
|
||||
|
||||
setClient( q.ns );
|
||||
strncpy(currentOp().ns, q.ns, Namespace::MaxNsLen);
|
||||
strncpy(currentOp.ns, q.ns, Namespace::MaxNsLen);
|
||||
msgdata = runQuery(m, ss ).release();
|
||||
}
|
||||
catch ( AssertionException& e ) {
|
||||
|
@ -25,9 +25,7 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
CurOp& currentOp();
|
||||
vector< CurOp >::const_iterator currentOpsBegin();
|
||||
vector< CurOp >::const_iterator currentOpsEnd();
|
||||
extern CurOp currentOp;
|
||||
|
||||
// turn on or off the oplog.* files which the db can generate.
|
||||
// these files are for diagnostic purposes and are unrelated to
|
||||
|
@ -1186,7 +1186,7 @@ namespace mongo {
|
||||
ss << "query " << ns << " ntoreturn:" << ntoreturn;
|
||||
{
|
||||
string s = jsobj.toString();
|
||||
strncpy(currentOp().query, s.c_str(), sizeof(currentOp().query)-1);
|
||||
strncpy(currentOp.query, s.c_str(), sizeof(currentOp.query)-1);
|
||||
}
|
||||
|
||||
BufBuilder bb;
|
||||
|
Loading…
Reference in New Issue
Block a user