|
In the output from db.currentOp(true), active ops have secs_running and microsecs_running fields which show how long it has been since the operation started.
However, these fields aren't present for ops which aren't currently active, which means that it's impossible to tell how long they have been there.
Possible solutions (in src/mongo/db/curop.cpp) include:
- Also including (micro)secs_running for ops which are inactive (but have started), eg. something like:
builder->append("active", a);
|
|
-if( a ) {
|
+if( isStarted() ) {
|
builder->append("secs_running", elapsedSeconds() );
|
builder->append("microsecs_running", static_cast<long long int>(elapsedMicros()) );
|
}
|
This would break anything that relies on these fields being present only when active is true (rather than directly checking for active: true).
- As above, but different field names for inactive ops, eg:
builder->append("active", a);
|
|
if( a ) {
|
builder->append("secs_running", elapsedSeconds() );
|
builder->append("microsecs_running", static_cast<long long int>(elapsedMicros()) );
|
+} else if (isStarted()) {
|
+ builder->append("secs_elapsed", elapsedSeconds() );
|
+ builder->append("microsecs_elapsed", elapsedMicros() );
|
}
|
- New fields always present for started ops, eg:
builder->append("active", a);
|
|
if( a ) {
|
builder->append("secs_running", elapsedSeconds() );
|
builder->append("microsecs_running", static_cast<long long int>(elapsedMicros()) );
|
}
|
+if (isStarted()) {
|
+ builder->append("secs_elapsed", elapsedSeconds() );
|
+ builder->append("microsecs_elapsed", elapsedMicros() );
|
+}
|
This would have the side effect of helping to resolve SERVER-18469 also.
- As well or instead of the above, but as a direct "started" field, eg:
builder->append("active", a);
|
|
+if (isStarted()) {
|
+ builder->append("started", _start ); // except converted to a BSON Date object
|
+}
|
+
|
if( a ) {
|
builder->append("secs_running", elapsedSeconds() );
|
builder->append("microsecs_running", static_cast<long long int>(elapsedMicros()) );
|
}
|
|