Hello,
I had some problems with a Ansible Module I’ve created for MongoDB and I think I’ve found a possible issue in 4.4.X
The docs detail the format for the config.tags collection…
{
"_id" : { "ns" : "records.users", "min" : { "zipcode" : "10001" } },
"ns" : "records.users",
"min" : { "zipcode" : "10001" },
"max" : { "zipcode" : "10281" },
"tag" : "NYC"
}
But in MongoDB 4.4.6 It seems to be the following. Note the value for _id…
{ "_id" : ObjectId("60e2e7cff7c9d447440bb114"), "ns" : "records.users", "min" : { "zipcode" : "10001" }, "max" : { "zipcode" : "10281" }, "tag" : "NYC" }
Raw output from my tests…
changed: [testhost] => {"changed": true, "cmd": ["mongo", "config", "--port", "27017", "-eval", "db.tags.find()"], "delta": "0:00:00.070870", "end": "2021-07-05 11:06:56.166165", "msg": "", "rc": 0, "start": "2021-07-05 11:06:56.095295", "stderr": "", "stderr_lines": [], "stdout": "MongoDB shell version v4.4.6\nconnecting to: mongodb://127.0.0.1:27017/config?compressors=disabled&gssapiServiceName=mongodb\nImplicit session: session { \"id\" : UUID(\"e664ff69-c422-499d-815e-c38af58a85ec\") }\nMongoDB server version: 4.4.6\n{ \"_id\" : ObjectId(\"60e2e7cff7c9d447440bb114\"), \"ns\" : \"records.users\", \"min\" : { \"zipcode\" : \"10001\" }, \"max\" : { \"zipcode\" : \"10281\" }, \"tag\" : \"NYC\" }\n{ \"_id\" : ObjectId(\"60e2e7cff7c9d447440bb11a\"), \"ns\" : \"records.users\", \"min\" : { \"zipcode\" : \"11201\" }, \"max\" : { \"zipcode\" : \"11240\" }, \"tag\" : \"NYC\" }", "stdout_lines": ["MongoDB shell version v4.4.6", "connecting to: mongodb://127.0.0.1:27017/config?compressors=disabled&gssapiServiceName=mongodb", "Implicit session: session { \"id\" : UUID(\"e664ff69-c422-499d-815e-c38af58a85ec\") }", "MongoDB server version: 4.4.6", "{ \"_id\" : ObjectId(\"60e2e7cff7c9d447440bb114\"), \"ns\" : \"records.users\", \"min\" : { \"zipcode\" : \"10001\" }, \"max\" : { \"zipcode\" : \"10281\" }, \"tag\" : \"NYC\" }", "{ \"_id\" : ObjectId(\"60e2e7cff7c9d447440bb11a\"), \"ns\" : \"records.users\", \"min\" : { \"zipcode\" : \"11201\" }, \"max\" : { \"zipcode\" : \"11240\" }, \"tag\" : \"NYC\" }"]}
This doesn’t happen when I tests with 4.2.14
TASK [mongodb_shard_zone : debug info] *****************************************
[512](https://github.com/ansible-collections/community.mongodb/pull/342/checks?
check_run_id=2989117121#step:8:512)changed: [testhost] => {"changed": true, "cmd": ["mongo",
"config", "--port", "27017", "-eval", "db.tags.find()"], "delta": "0:00:00.068731", "end": "2021-07-05
10:31:39.210795", "rc": 0, "start": "2021-07-05 10:31:39.142064", "stderr": "", "stderr_lines": [],
"stdout": "MongoDB shell version v4.2.14\nconnecting to: mongodb://127.0.0.1:27017/config?
compressors=disabled&gssapiServiceName=mongodb\nImplicit session: session { \"id\" :
UUID(\"0ca83622-5a1a-4ddc-a3fd-9f634ef51bff\") }\nMongoDB server version: 4.2.14\n{ \"_id\" : {
\"ns\" : \"records.users\", \"min\" : { \"zipcode\" : \"10001\" } }, \"ns\" : \"records.users\", \"min\" : {
\"zipcode\" : \"10001\" }, \"max\" : { \"zipcode\" : \"10281\" }, \"tag\" : \"NYC\" }\n{ \"_id\" : { \"ns\" :
\"records.users\", \"min\" : { \"zipcode\" : \"11201\" } }, \"ns\" : \"records.users\", \"min\" : { \"zipcode\" :
\"11201\" }, \"max\" : { \"zipcode\" : \"11240\" }, \"tag\" : \"NYC\" }", "stdout_lines": ["MongoDB shell
version v4.2.14", "connecting to: mongodb://127.0.0.1:27017/config?
compressors=disabled&gssapiServiceName=mongodb", "Implicit session: session { \"id\" :
UUID(\"0ca83622-5a1a-4ddc-a3fd-9f634ef51bff\") }", "MongoDB server version: 4.2.14", "{ \"_id\" : {
\"ns\" : \"records.users\", \"min\" : { \"zipcode\" : \"10001\" } }, \"ns\" : \"records.users\", \"min\" : {
\"zipcode\" : \"10001\" }, \"max\" : { \"zipcode\" : \"10281\" }, \"tag\" : \"NYC\" }", "{ \"_id\" : { \"ns\" :
\"records.users\", \"min\" : { \"zipcode\" : \"11201\" } }, \"ns\" : \"records.users\", \"min\" : { \"zipcode\" :
\"11201\" }, \"max\" : { \"zipcode\" : \"11240\" }, \"tag\" : \"NYC\" }"]}
Records are added using updateZoneKeyRange
with Python/pymongo
Rhys