TylerBrock / mongo-hacker

MongoDB Shell Enhancements for Hackers
tylerbrock.github.io/mongo-hacker
MIT License
1.79k stars 235 forks source link

sh.getBalancerLockDetails is not a function #197

Closed kagahd closed 5 years ago

kagahd commented 6 years ago

sh.status wont work anymore:

mongo-seometadata-01(mongos-3.4.15)[mongos] seo-metadata> sh.status()
2018-09-14T15:46:54.883+0200 E QUERY    [js] TypeError: sh.getBalancerLockDetails is not a function :
printShardingStatus@/Users/kay.agahd/.mongorc.js:1600:23
sh.status@src/mongo/shell/utils_sh.js:89:5
@(shell):1:1
kagahd commented 6 years ago

If I replace line 1600 in mongorc.js by var balLock = false; it works:

mongo-seometadata-01(mongos-3.4.15)[mongos] test> sh.status()
--- Sharding Status ---
  sharding version: {
    "_id": 1,
    "minCompatibleVersion": 5,
    "currentVersion": 6,
    "clusterId": ObjectId("5b7be78084f669d75d0fa6d7")
  }
  shards:
kagahd commented 6 years ago

The reason is that sh.getBalancerLockDetails() no longer exists in 3.6 and my mongo shell is v4.0 see: https://jira.mongodb.org/browse/DOCS-11135 Also, if the cluster has a sharded database, sh.status()will fail:

mongo-offerstore-de-01(mongos-3.2.19)[mongos] test> sh.status()
2018-09-14T16:03:53.420+0200 E QUERY    [js] Error: command failed: {
  "ok": 0,
  "errmsg": "no such cmd: balancerStatus",
  "code": 59
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:534:17
assert.commandWorked@src/mongo/shell/assert.js:618:16
sh.isBalancerRunning@src/mongo/shell/utils_sh.js:156:12
printShardingStatus@/Users/kay.agahd/.mongorc.js:1597:24
sh.status@src/mongo/shell/utils_sh.js:89:5
@(shell):1:1

My workaround is to replace line 1597 of mongorc.js

colorize("dont know", {color: "gray"}) );
//colorize(( sh.isBalancerRunning() ? "yes" : "no" ), {color: "gray"}) );