How to fix duplicate key error?

Hi all,

in the Rocket.Chat log we find some entries with this error from time to time:

BulkWriteError: E11000 duplicate key error index: rocketchat.rocketchat_message_read_receipt.$roomId_1_userId_1_messageId_1 dup key

Which impacts does this error have? We do not have any negative feedbacks from the user at the moment.

And how can I fix this error? Would it be possible to delete and recreate the index?

Many thanks and best regards
Daniel

Server Setup Information

Rocket.Chat Version: 0.74.3 (official docker image)
NodeJS Version: 8.11.4 - x64
Platform: linux
ReplicaSet OpLog: Disabled
Commit Hash: 202a465f1c
Commit Branch: HEAD

UnhandledPromiseRejectionWarning: BulkWriteError: E11000 duplicate key error index: rocketchat.rocketchat_message_read_receipt.$roomId_1_userId_1_messageId_1 dup key: { : “CQCiDReLaACktKJh5”, : “cfHaaDNFf7eAkZ8mat”, : “C78A7wsrTnFFZ9bP” }
at OrderedBulkOperation.handleWriteError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/bulk/common.js:1048:11)
at resultHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/bulk/ordered.js:159:23)
at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:532:18
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

1 Like

Any update on this?

Thanks

I found a fix in this Pull Request: https://github.com/RocketChat/Rocket.Chat/pull/18560/files.

Hi @dtvu94 I’m having this same error. What in there was the fix? I’m on RC v4.6.4

UnhandledPromiseRejectionWarning: MongoError: E11000 duplicate key error index: rocketchat.rocketchat_read_receipts.$roomId_1_userId_1_messageId_1 dup key: { : "NLxKivHtReRL8xq6xq68Lkgn49GdQwT8u8", : "NLxKivHtReRL8xq6x", : "92WQdFhpybGM56a4x" }