Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-18470

Give some indication of age of inactive ops in currentOp

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Diagnostics
    • Query Execution

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

      Attachments

        Activity

          People

            backlog-query-execution Backlog - Query Execution
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated: