mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-30 09:06:21 +01:00
track last op in Client
This commit is contained in:
parent
c790fe6b82
commit
f078b67f18
10
db/client.h
10
db/client.h
@ -162,6 +162,7 @@ namespace mongo {
|
||||
const char *_desc;
|
||||
bool _god;
|
||||
AuthenticationInfo _ai;
|
||||
OpTime _lastOp;
|
||||
|
||||
public:
|
||||
|
||||
@ -182,6 +183,15 @@ namespace mongo {
|
||||
void addTempCollection( const string& ns ){
|
||||
_tempCollections.push_back( ns );
|
||||
}
|
||||
|
||||
void setLastOp( const OpTime& op ){
|
||||
_lastOp = op;
|
||||
}
|
||||
|
||||
void appendLastOp( BSONObjBuilder& b ){
|
||||
if ( ! _lastOp.isNull() )
|
||||
b.appendTimestamp( "lastOp" , _lastOp.asDate() );
|
||||
}
|
||||
|
||||
/* each thread which does db operations has a Client object in TLS.
|
||||
call this when your thread starts.
|
||||
|
@ -140,6 +140,8 @@ namespace mongo {
|
||||
else
|
||||
le->appendSelf( result );
|
||||
|
||||
cc().appendLastOp( result );
|
||||
|
||||
if ( cmdObj["fsync"].trueValue() ){
|
||||
log() << "fsync from getlasterror" << endl;
|
||||
result.append( "fsyncFiles" , MemoryMappedFile::flushAll( true ) );
|
||||
|
@ -236,8 +236,10 @@ namespace mongo {
|
||||
i.loc = new OpTime[1];
|
||||
i.loc[0] = last;
|
||||
_dirty = true;
|
||||
if ( ! _started )
|
||||
if ( ! _started ){
|
||||
_started = true;
|
||||
go();
|
||||
}
|
||||
}
|
||||
|
||||
// need to be careful not to deadlock with this
|
||||
@ -1719,8 +1721,10 @@ namespace mongo {
|
||||
BSONObj temp(r);
|
||||
log( 6 ) << "logging op:" << temp << endl;
|
||||
}
|
||||
|
||||
context.getClient()->setLastOp( ts );
|
||||
}
|
||||
|
||||
|
||||
static void logKeepalive() {
|
||||
BSONObj obj;
|
||||
_logOp("n", "", "local.oplog.$main", obj, 0, 0, OpTime::now());
|
||||
|
Loading…
Reference in New Issue
Block a user