I have big codebase and I saw that in logs, so actually now it’s hard to tell how (code) exactly the error printed in stderr, but I have stack of the error, may be it will be useful:
MongoServerError: Erroneous index key found with reference to non-existent record id. Consider dropping and then re-creating the index and then running the validate command on the collection.
at MessageStream.messageHandler (/home/user/project/node_modules/mongodb/lib/cmap/connection.js:467:30)
at MessageStream.emit (node:events:390:28)
at MessageStream.emit (node:domain:537:15)
at processIncomingData (/home/user/project/node_modules/mongodb/lib/cmap/message_stream.js:108:16)
at MessageStream._write (/home/user/project/node_modules/mongodb/lib/cmap/message_stream.js:28:9)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:537:15)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
Any idea what could have caused this issue?
We tried to migrate to MongoDB v5 from v4 but found that our CPUs don’t support AVX.
Anyway somehow our admin team managed to compile and run v5 without it but soon we saw it was not stable
and crashing, so we downgraded to v4. I’m not sure what they were doing exactly with database
files as I was not involved in the work, may be because v5 was crashing and somehow we got one
index corrupted because of that.