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

Give some indication of age of inactive ops in currentOp

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Diagnostics
    • Labels:
    • Query Execution

      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:
        Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
         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:
        Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
         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:
        Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
         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:
        Unable to find source-code formatter for language: diff. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
         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()) );
         }
        

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: