Good afternoon,
MongoDB server version: 3.6.16 on RHEL/CentOS.
I am trying to insert a record into a sharded collection, and I am getting a strange error I have Googled the heck out of. To summarize, the insert says: “shard version not ok: version mismatch detected for MYDATABASE.MYCOLLECTION”. What causes this? I have tried to do a flushRouterConfig with no avail.
The following is the log line I that I have changed to protect the innocent:
2020-07-22T16:23:45.805+0000 I COMMAND [conn1189005] command MYDATABASE.MYCOLLECTION command: insert { insert: “MYCOLLECTION”, bypassDocumentValidation: false, ordered: false, documents: 50, shardVersion: [ Timestamp(57023, 3), ObjectId(‘57c5ff81724c2e70c623e733’) ], lsid: { id: UUID(“fade92f1-0993-4db7-af03-1b6066628f8c”), uid: BinData(0, 30D9CB0F31D33F7912528ADD7F28D77AA3ADBBDF1B6E9C50BFB8163217CE97C8) }, $clusterTime: { clusterTime: Timestamp(1595435024, 596), signature: { hash: BinData(0, E82B2EB1A3E65A615144ABFD585CC0CB8DB8E2D0), keyId: 6817327097028018329 } }, $client: { driver: { name: “mongo-java-driver”, version: “3.9.1” }, os: { type: “Linux”, name: “Linux”, architecture: “amd64", version: “3.10.0-1127.el7.x86_64” }, platform: “Java/Oracle Corporation/1.8.0_181-b13", mongos: { host: “queryrouter:27018”, client: “xxx.xxx.xxx.xxx:49626", version: “3.6.16” } }, $configServerState: { opTime: { ts: Timestamp(1595435023, 177), t: 4071 } }, $db: “MYDATABASE” } ninserted:0 exception: shard version not ok: version mismatch detected for MYDATABASE.MYCOLLECTION ( ns : MYDATABASE.MYCOLLECTION, received : 57023|3||57c5ff81724c2e70c623e733, wanted : 57024|3||57c5ff81724c2e70c623e733 ) code:StaleConfig numYields:0 reslen:14363 locks:{ Global: { acquireCount: { r: 4, w: 2 } }, Database: { acquireCount: { r: 1, w: 2 } }, Collection: { acquireCount: { r: 1, w: 2 }, acquireWaitCount: { w: 1 }, timeAcquiringMicros: { w: 1432380 } } } protocol:op_msg 1432ms
it’s always on the same object ID, and we have over 2000-3000 errors daily. Mongo cannot find the objectID:
mongos> db.MYCOLLECTION.find({_id :
ObjectId("57c5ff81724c2e70c623e733" });
Also running below and restarting all the query routers did not fix it:
db.adminCommand({ flushRouterConfig: “MYDATABASE.MYCOLLECTION”});
Please assist.