rocketchat_subscription collection keeps a user records when the user is deleted.
If deleted user is registered again with the same user name, then any attempt to make rocketchat_subscription record (add him to private messages) causes an error:
MongoError: E11000 duplicate key error index: chat.rocketchat_subscription.$u._id_1_name_1_t_1 dup key
Reproducing steps:
newuserregisteredanotherusernewuserregisterednewuserregisteredanotheruser -> bugAny suggestions on how to resolve this issue manually? We have this bad state with a user right now and want to resolve it.
You have to delete the Subscriptions from the collection rocketchat_subscription using the filter like {"name": "USERNAME-HERE"}
Thank you for the response!
I did that, but it left me with a problem where I couldn't send direct messages to some people I had direct messaged with my other account. Here's how I solved it all:
Ran:
use mydb
db.users.find(
{"username":"kwalton"}
) <-- just to make sure the user existed
db.users.remove(
{"username":"kwalton"}
) <-- deletes the user
Then I re-logged in to Rocket.Chat and it worked. But I ran into another issue where I couldn't direct message someone, so I went back into mongo and:
use mydb
db.rocketchat_subscription.find({"name":"kwalton"}) <-- copied the rid value for the person and my conversation
db.rocketchat_subscription.remove({"name":"kwalton"}) <-- deletes my subscriptions
db.rocketchat_room.find({"_id":"
db.rocketchat_room.remove({"_id":"
Also found any other rooms that matched the other person and I:
db.rocketchat_room.find({"usernames" : [ "theotherperson", "kwalton" ]})
db.rocketchat_room.remove({"usernames" : [ "theotherperson", "kwalton" ]}) <-- removed all rooms between us, appeared to be a dupe in there causing trouble
Then direct messages between the other person and I worked. We're all good now :)
we deleted one of our users who was having a direct message with some of other users. then we created a new account with the same username.
when trying to open up a direct message with the same people, we got a 500 internal server error.
so we followed @kalebwalton's manual solution and it seemed to work. we didn't get the 500 internal server error anymore. however, now it says "No user with username was found!" when trying to access the direct message.
Solution provided by @kalebwalton worked for me, thanks !
Problem still exists with v0.57. :(
The provided solution is just a nasty workaround - shouldn't the problem still be fixed?
I am not sure how to apply this at all. Isn't there some other way that does not involve messing with the datastore?
Exception while invoking method 'createDirectMessage' MongoError:
E11000 duplicate key error collection: parties.rocketchat_subscription index: u._id_1_name_1_t_1_code_1 dup key:
{ : "RWmMv7vkye3Kb7Ao8", : "fmuecke", : "d", : null }
at Object.Future.wait (/snap/rocketchat-server/829/node_modules/fibers/future.js:449:15)
Most helpful comment
Thank you for the response!
I did that, but it left me with a problem where I couldn't send direct messages to some people I had direct messaged with my other account. Here's how I solved it all:
Ran:"}) <-- just to make sure the room exists"}) <-- remove the room
use mydb
db.users.find(
{"username":"kwalton"}
) <-- just to make sure the user existed
db.users.remove(
{"username":"kwalton"}
) <-- deletes the user
Then I re-logged in to Rocket.Chat and it worked. But I ran into another issue where I couldn't direct message someone, so I went back into mongo and:
use mydb
db.rocketchat_subscription.find({"name":"kwalton"}) <-- copied the rid value for the person and my conversation
db.rocketchat_subscription.remove({"name":"kwalton"}) <-- deletes my subscriptions
db.rocketchat_room.find({"_id":"
db.rocketchat_room.remove({"_id":"
Also found any other rooms that matched the other person and I:
db.rocketchat_room.find({"usernames" : [ "theotherperson", "kwalton" ]})
db.rocketchat_room.remove({"usernames" : [ "theotherperson", "kwalton" ]}) <-- removed all rooms between us, appeared to be a dupe in there causing trouble
Then direct messages between the other person and I worked. We're all good now :)