[SERVER-14492] db.currentOp() limited to 5 (five) operations? Created: 07/Jul/14  Updated: 10/Dec/14  Resolved: 07/Jul/14

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

Type: Question Priority: Major - P3
Reporter: Dan Dascalescu Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Is db.currentOp() limited to 5 operations? I've never seen more than five entries returned in the inprog array. If so, that should be documented.

I'm also experiencing what appears to be zombie queries: running db.currentOp() several times (varies from 5 to over 20) in a row outputs 5 query operations with secs_running: 0, after which it outputs an empty inprog. The connection IDs are the same conn55-conn59 but the opids keep changing and the queries are different. It seems as if db.currentOp() displays a history of queries rather. Here's one output:

mongod-2.4.10| stockbase-prod> db.currentOp()
{
  "inprog": [
    {
      "active": true,
      "client": "127.0.0.1:51757",
      "connectionId": 55,
      "desc": "conn55",
      "lockStats": {
        "timeAcquiringMicros": {
          "r": NumberLong("167661"),
          "w": NumberLong("0")
        },
        "timeLockedMicros": {
          "r": NumberLong("185231"),
          "w": NumberLong("0")
        }
      },
      "ns": "stockbase-prod.companies",
      "numYields": 17,
      "op": "query",
      "opid": 4637790,
      "query": {
        "$query": {
          "symbol": {
            "$options": "i",
            "$regex": "^.+itpc"
          }
        },
        "orderby": {
          "symbol": 1
        }
      },
      "secs_running": 0,
      "threadId": "0x7f9fa8ee9700",
      "waitingForLock": false
    },
    {
      "active": true,
      "client": "127.0.0.1:51760",
      "connectionId": 58,
      "desc": "conn58",
      "lockStats": {
        "timeAcquiringMicros": {
          "r": NumberLong("115074"),
          "w": NumberLong("0")
        },
        "timeLockedMicros": {
          "r": NumberLong("169989"),
          "w": NumberLong("0")
        }
      },
      "ns": "stockbase-prod.companies",
      "numYields": 17,
      "op": "query",
      "opid": 4637792,
      "query": {
        "$query": {
          "symbol": {
            "$options": "i",
            "$regex": "^.+bfcf"
          }
        },
        "orderby": {
          "symbol": 1
        }
      },
      "secs_running": 0,
      "threadId": "0x7f9fa91ec700",
      "waitingForLock": false
    },
    {
      "active": true,
      "client": "127.0.0.1:51761",
      "connectionId": 59,
      "desc": "conn59",
      "lockStats": {
        "timeAcquiringMicros": {
          "r": NumberLong("143480"),
          "w": NumberLong("0")
        },
        "timeLockedMicros": {
          "r": NumberLong("189736"),
          "w": NumberLong("0")
        }
      },
      "ns": "stockbase-prod.companies",
      "numYields": 16,
      "op": "query",
      "opid": 4637791,
      "query": {
        "$query": {
          "symbol": {
            "$options": "i",
            "$regex": "^.+sfl"
          }
        },
        "orderby": {
          "symbol": 1
        }
      },
      "secs_running": 0,
      "threadId": "0x7f9fa92ed700",
      "waitingForLock": false
    },
    {
      "active": true,
      "client": "127.0.0.1:51759",
      "connectionId": 57,
      "desc": "conn57",
      "lockStats": {
        "timeAcquiringMicros": {
          "r": NumberLong("47742"),
          "w": NumberLong("0")
        },
        "timeLockedMicros": {
          "r": NumberLong("81799"),
          "w": NumberLong("0")
        }
      },
      "locks": {
        "^": "r",
        "^stockbase-prod": "R"
      },
      "ns": "stockbase-prod.companies",
      "numYields": 1,
      "op": "query",
      "opid": 4637793,
      "query": {
        "$query": {
          "symbol": {
            "$options": "i",
            "$regex": "^.+lvnta"
          }
        },
        "orderby": {
          "symbol": 1
        }
      },
      "secs_running": 0,
      "threadId": "0x7f9fa90eb700",
      "waitingForLock": false
    },
    {
      "active": true,
      "client": "127.0.0.1:51758",
      "connectionId": 56,
      "desc": "conn56",
      "lockStats": {
        "timeAcquiringMicros": {
          "r": NumberLong("44177"),
          "w": NumberLong("0")
        },
        "timeLockedMicros": {
          "r": NumberLong("74988"),
          "w": NumberLong("0")
        }
      },
      "locks": {
        "^": "r",
        "^stockbase-prod": "R"
      },
      "ns": "stockbase-prod.companies",
      "numYields": 1,
      "op": "query",
      "opid": 4637794,
      "query": {
        "$query": {
          "symbol": {
            "$options": "i",
            "$regex": "^lvnta"
          }
        },
        "orderby": {
          "symbol": 1
        }
      },
      "secs_running": 0,
      "threadId": "0x7f9fa8fea700",
      "waitingForLock": false
    }
  ]
}



 Comments   
Comment by Dan Dascalescu [ 07/Jul/14 ]

Thanks Thomas. The issue must be related to the application (Meteor). Indeed, Meteor seems to be opening 5 connections to Mongo at a time.

Comment by Thomas Rueckstiess [ 07/Jul/14 ]

Hi Dan,

The currentOp() output is not limited to 5 queries, and it shows all operations currently running, not a history. If you want to look at the history of queries, you can Enable Profiling or refer to the log file.

This looks to me that you might have 5 connections open to the database, that are all sending operations. You'd see 5 at the same time at each given point in time, the connection ids remain the same but the opids change because they are different operations.

"secs_running": 0 indicates that they are fast, and sometimes you might catch a currentOp() where none are running at that exact moment. Think of it as taking a photo of a 5-lane highway (where a lane is a connection), you may see up to 5 cars in one picture, but sometimes less or even 0, depending on traffic.

If you have more questions about how currentOp works, please post your question on the mongodb-users group (http://groups.google.com/group/mongodb-user) or Stack Overflow with the mongodb tag.

Regards,
Thomas

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