-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
read_receipts MongoError: Index build failed #26259
Comments
Same here with Rocket.Chat: Version 5.0.0 Occours after upgrade from 4.8.2 -> 5.0.0. Log-File shows:
Any help is greatly appreciated. |
Same duplicate key message error here: Version 5.0.0 And I did upgrade from 4.8.2, but had to do a mongodump, fresh install, mongorestore to be able to have Rocket.Chat running (I never saw the important note about adding ?replicaSet=rs0&directConnection=true for MONGO_URL and MONGO_OPLOG_URL). |
Had the same problem / error messages but with different indexes, fixed it via mongosh: db.users.dropIndexes() Found it here: #24347 (comment) |
Here is my solution if it helps anyone.
var duplicates = [];
db.getCollection("rocketchat_read_receipts").aggregate([
{
"$group": {
"_id": { "roomId": "$roomId", "userId": "$userId", "messageId": "$messageId" },
"uniqueIds": { "$addToSet": "$_id" },
"count": { "$sum": 1 }
}
},
{ "$match": { "count": { "$gt": 1 } } }
],
{ allowDiskUse: true }
)
.forEach(function (doc) {
// remove 1st element
doc.uniqueIds.shift();
doc.uniqueIds.forEach(function (dupId) {
duplicates.push(dupId);
}
)
})
printjson(duplicates);
db.getCollection("rocketchat_read_receipts").remove({ _id: { $in: duplicates } });
|
I have the same problem and the above script gets nothing ( [ ] )... even when I try and manually find the entry with the _id I get nothing. but whenever I restart the server the error comes again 🤔 Edit: nevermind, I had the wrong DB in use. But damn it returns many duplicates 😅. Will have to test this at night so I can restore if things go south |
Jodanah, your idea is excellent but there is problem running script. Please help fixing it ;) ....... |
@Alfs29 there are no problems with the script (huge thanks @jadanah), you just can't run it like this from mongo shell, try it like this (4 separate commands):
|
Anyone come across this before/have a fix?
After upgrade (docker) from 4.7.0 -> 4.8.1
| Rocket.Chat Version: 4.8.1 |
| NodeJS Version: 14.18.3 - x64 |
| MongoDB Version: 5.0.9 |
Error creating indexes for read_receipts MongoError: Index build failed: 42a676ef-774f-4ed9-a97a-0791bf2b705a: Collection rocketchat.rocketchat_read_receipts ( f996721f-c895-4221-b308-a1ae10e5e4e0 ) :: caused by :: E11000 duplicate key error collection: rocketchat.rocketchat_read_receipts index: roomId_1_userId_1_messageId_1 dup key: { roomId: "8Msort4RJKCHhgun2M6RSWhdssRGstwMSp", userId: "8Msort4RJKCHhgun2", messageId: "vCvXNfzET7ZXYTv58" }
at MessageStream.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connection.js:272:20)
at MessageStream.emit (events.js:400:28)
at MessageStream.emit (domain.js:475:12)
at processIncomingData (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
at MessageStream.write (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
at writeOrBuffer (internal/streams/writable.js:358:12)
at MessageStream.Writable.write (internal/streams/writable.js:303:10)
at Socket.ondata (internal/streams/readable.js:731:22)
at Socket.emit (events.js:400:28)
at Socket.emit (domain.js:475:12)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at Socket.Readable.push (internal/streams/readable.js:206:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
at TCP.callbackTrampoline (internal/async_hooks.js:130:17) {
ok: 0,
code: 11000,
codeName: 'DuplicateKey',
keyPattern: { roomId: 1, userId: 1, messageId: 1 },
keyValue: {
roomId: '8Msort4RJKCHhgun2M6RSWhdssRGstwMSp',
userId: '8Msort4RJKCHhgun2',
messageId: 'vCvXNfzET7ZXYTv58'
},
'$clusterTime': {
clusterTime: Timestamp { bsontype: 'Timestamp', low: 3, high: 1657757757 },
signature: { hash: [Binary], keyId: 0 }
},
operationTime: Timestamp { bsontype: 'Timestamp', low: 3, high_: 1657757757 }
}
The text was updated successfully, but these errors were encountered: