[SERVER-18470] Give some indication of age of inactive ops in currentOp Created: 14/May/15  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Diagnostics
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kevin Pulo Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 1
Labels: curop, currentop
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-18469 Improve naming of secs_running / micr... Closed
is related to SERVER-26705 Need a command that lists all connect... Backlog
Assigned Teams:
Query Execution
Participants:

 Description   

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:

  1. 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).

  2. 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() );
     }
    


  3. 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.

  4. 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()) );
     }
    


Generated at Thu Feb 08 03:47:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.