About the slave library of one shard, why do you count the libraries in another shard?

mongo Cluster

mongos> sh.status()
databases:
    {  "_id" : "foo",  "primary" : "shard1",  "partitioned" : false }
    {  "_id" : "bar",  "primary" : "shard0",  "partitioned" : false }

access shard1 from

mongo 127.0.0.1:28010

execute the following command in mongo shell

shard1:SECONDARY> db.currentOp(    {      "active" : true,      "secs_running" : { "$gt" : 10 }    } )

    {
  "desc": "conn1041165",
  "threadId": "139624352057088",
  "connectionId": 1041165,
  "client": "192.168.0.1:54368",
  "active": true,
  "opid": 61729430,
  "secs_running": 42746,
  "microsecs_running": NumberLong("42746814047"),
  "op": "command",
  "ns": "bar",
  "query": {
    "dbstats": 1
  },
  "numYields": 0,
  "locks": {
    "Global": "r"
  },
  "waitingForLock": false,
  "lockStats": {
    "Global": {
      "acquireCount": {
        "r": NumberLong(1)
      }
    }
  }
}
],
"ok": 1
}
...

it"s strange to find that there are many of the above queries about shard1. Why do you want to count shard0"s library? And why did it take so long to execute for almost 12 hours

"dbstats": 1 is it corresponding to the following command

> db.stats()
{
    "db" : "test",
    "collections" : 73,
    "objects" : 246794,
    "avgObjSize" : 2915.7151713574885,
    "dataSize" : 719581010,
    "storageSize" : 787140608,
    "numExtents" : 0,
    "indexes" : 85,
    "indexSize" : 11505664,
    "ok" : 1
}


Mar.15,2021

about {dbstats: 1} meaning:

  • query condition is {dbstats: 1} ( {"query": {"dbstats": 1}} )
  • the library name is bar ( {ns: 'bar'} )
  • performs the command operation ( {op: 'command'} )

so the statement executed is:

db.runCommand({dbstats: 1});

it is actually the inner operation of the db.stats () method:

rs0:PRIMARY> db.stats
function (scale) {
    return this.runCommand({dbstats: 1, scale: scale});
}
< hr >
mongos> sh.status()
databases:
    {  "_id" : "foo",  "primary" : "shard1",  "partitioned" : false }
    {  "_id" : "bar",  "primary" : "shard0",  "partitioned" : false }

this output means that there are now two collections, foo / bar , both of which have no shards ( {"partitioned": false} ), and since there are no shards, only one shard is actually carrying them. On shard1 / shard0 ( {"primary": "shard1"} / {"primary": "shard0"} ), it is not a library in another shard that you understand. Furthermore, this command is executed from mongos, mongos is already connected to all the shards, and there is no so-called statistical "another shard".

< hr > It is true that db.stats () should not have been executed for so long because the last execution time of

is too long. This problem may have something to do with a specific version of bug, or it may have something to do with your environment, which requires a specific analysis of the log. It is recommended to go to jira.mongodb.org to open ticket to inquire about the situation.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e43627-44a32.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e43627-44a32.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?