Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Deleting a user doesn't delete rocketchat_subscription's for DM's

Open 12test12 opened this issue 9 years ago • 51 comments

Rocket.Chat Version: 0.54.2 Running Instances: 1 DB Replicaset OpLog: Disabled Node Version: 4.8.1

I had the same problem like #1149.

I followed kalebwalton solution step to solve the problem.

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":""}) <-- just to make sure the room exists db.rocketchat_room.remove({"_id":""}) <-- remove the room 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

But now I have an other problem. Now it says "No user with username was found!" when trying to access the direct message. issue

12test12 avatar Mar 30 '17 13:03 12test12

need this to be fixed

willihelm avatar Apr 12 '17 12:04 willihelm

Fixed this by deleting the subscriptions of the effected users in mongoDB. After that I had to restart the server and the users had to relogin.

willihelm avatar Apr 19 '17 09:04 willihelm

How looks your mongodb-Query?

Reamer avatar Apr 19 '17 10:04 Reamer

db.getCollection('rocketchat_subscription').find({ "name": "username1", $and: [ { "u.username": "username2" } ] }) db.getCollection('rocketchat_subscription').find({ "name": "username2", $and: [ { "u.username": "username1" } ] })

willihelm avatar Apr 19 '17 11:04 willihelm

Bug is still here, i just observed a couple users with this issue, it's really time consuming for the server admin

x-drum avatar May 24 '17 09:05 x-drum

0.56.0: Issue is there. Discovered it when trying to DM.

ellisgl avatar May 24 '17 22:05 ellisgl

So I was playing with on my local VM and it seems that it works fine there, but there is a difference between my local VM and the bigger test bed, is that mine complains about how I don't have my MongoDB on ReplicaSet mode.

Error: Rocket.Chat requires oplog tailing when running in multiple instances
Please make sure your MongoDB is on ReplicaSet mode and MONGO_OPLOG_URL environment variable is defined correctly on the application server

Wonder if having it in ReplicaSet mode could be causing it not to work?

Well the first post said he didn't have ReplicaSet on.. So that that's probably not it. I did see a bunch of stuff about caching around the queries.

ellisgl avatar May 25 '17 01:05 ellisgl

Same issue with deleted/recreated user.

cturcich-catasys avatar Jul 07 '17 13:07 cturcich-catasys

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. Is 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)

fmuecke avatar Jul 27 '17 12:07 fmuecke

Hi,

I removed the user account, every subscription and then restarted everything. Same problem. I can't dm the user. Anything else I can do?

I'm using 0.57.2

kiamgrebgnur avatar Aug 07 '17 11:08 kiamgrebgnur

Any progress on this?

cturcich-catasys avatar Aug 09 '17 17:08 cturcich-catasys

Same problem here :\

Any progress on this?

jhonatanmorais avatar Aug 11 '17 15:08 jhonatanmorais

Same Here, below error on 0.58.0 on Docker with Oplog enabled:

Exception while invoking method 'createDirectMessage' MongoError: E11000 duplicate key error collection: rocketchat.rocketchat_subscription index: u._id_1_name_1_t_1_code_1 dup key: { : "GbFCZzXFtPbp9JEA8", : "XXXXX", : "d", : null }

  at [object Object].<anonymous> (packages/meteor.js:213:24)
  at [object Object].MongoConnection.(anonymous function) [as update] (/app/bundle/programs/server/packages/mongo.js:835:49)
  at Object.<anonymous> (packages/matb33_collection-hooks.js:504:27)
  at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks.js:146:21)
  at [object Object].update (/app/bundle/programs/server/packages/mongo.js:3917:31)
  at ModelsBaseDb.update (/app/bundle/programs/server/packages/rocketchat_lib.js:10914:32)
  at ModelsBaseDb.upsert (/app/bundle/programs/server/packages/rocketchat_lib.js:10989:16)
  at ModelSubscriptions.upsert (/app/bundle/programs/server/packages/rocketchat_lib.js:4486:36)
  at [object Object].Meteor.methods.createDirectMessage (/app/bundle/programs/server/app/app.js:6585:35)
  at [object Object].methodMap.(anonymous function) (packages/rocketchat_monitoring.js:2731:30)
  at [object Object].methodsMap.(anonymous function) (/app/bundle/programs/server/packages/rocketchat_lib.js:1110:26)
  at maybeAuditArgumentChecks (/app/bundle/programs/server/packages/ddp-server.js:1858:12)
  at /app/bundle/programs/server/packages/ddp-server.js:904:20
  at [object Object]._.extend.withValue (packages/meteor.js:1126:17)
  at /app/bundle/programs/server/packages/ddp-server.js:903:47
  at [object Object]._.extend.withValue (packages/meteor.js:1126:17)
  at /app/bundle/programs/server/packages/ddp-server.js:902:46
  at [object Object]._.extend.protocol_handlers.method (/app/bundle/programs/server/packages/ddp-server.js:875:21)
  at /app/bundle/programs/server/packages/ddp-server.js:754:85

    - - - - -
  at Function.MongoError.create (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/error.js:31:11)
  at toError (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:114:22)
  at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/collection.js:1049:67
  at /app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:455:18
  at nextTickCallbackWith0Args (node.js:489:9)
  at process._tickDomainCallback (node.js:459:13)```

nitinbhadauria avatar Aug 18 '17 03:08 nitinbhadauria

Same problem here, a user has been deleted and then created again using custom Oauth (IdentityServer) login implementation. Direct chat to this username throws "username not found".

[34mI20170920-10:01:21.730(0) Exception while invoking method 'createDirectMessage' MongoError: E11000 duplicate key error index: rocketchat.rocketchat_subscription.$u._id_1_name_1_t_1_code_1 dup key: { : "W9TGtB4KCYxzfj3hR", : "Malou.Runnemo", : "d", : null } at Object.Future.wait (/opt/Rocket.Chat/programs/server/node_modules/fibers/future.js:449:15) at [object Object].<anonymous> (packages/meteor.js:213:24) at [object Object].MongoConnection.(anonymous function) [as update] (/opt/Rocket.Chat/programs/server/packages/mongo.js:836:49) at Object.<anonymous> (packages/matb33_collection-hooks.js:504:27) at Object.collection.(anonymous function) [as update] (packages/matb33_collection-hooks.js:146:21) at [object Object].update (/opt/Rocket.Chat/programs/server/packages/mongo.js:3899:31) at ModelsBaseDb.update (/opt/Rocket.Chat/programs/server/packages/rocketchat_lib.js:10647:32) at ModelsBaseDb.upsert (/opt/Rocket.Chat/programs/server/packages/rocketchat_lib.js:10722:16) at ModelSubscriptions.upsert (/opt/Rocket.Chat/programs/server/packages/rocketchat_lib.js:4283:36) at [object Object].Meteor.methods.createDirectMessage (/opt/Rocket.Chat/programs/server/app/app.js:6506:35) at [object Object].methodMap.(anonymous function) (packages/rocketchat_monitoring.js:2731:30) at [object Object].methodsMap.(anonymous function) (/opt/Rocket.Chat/programs/server/packages/rocketchat_lib.js:1028:26) at maybeAuditArgumentChecks (/opt/Rocket.Chat/programs/server/packages/ddp-server.js:1823:12) at /opt/Rocket.Chat/programs/server/packages/ddp-server.js:905:20 at [object Object]._.extend.withValue (packages/meteor.js:1122:17) at /opt/Rocket.Chat/programs/server/packages/ddp-server.js:904:41 at [object Object]._.extend.withValue (packages/meteor.js:1122:17) at /opt/Rocket.Chat/programs/server/packages/ddp-server.js:903:46 at [object Object]._.extend.protocol_handlers.method (/opt/Rocket.Chat/programs/server/packages/ddp-server.js:876:21) at /opt/Rocket.Chat/programs/server/packages/ddp-server.js:755:85 - - - - - at Function.MongoError.create (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/error.js:31:11) at toError (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:114:22) at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/collection.js:1049:67 at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:455:18 at nextTickCallbackWith0Args (node.js:420:9) at process._tickDomainCallback (node.js:390:13)

bsubasic avatar Sep 20 '17 10:09 bsubasic

I am seeing the same issue as well. Thanks.

metalcated avatar Nov 14 '17 15:11 metalcated

Is anything gonna be done to solve this? I've had a conversation that I'm unable to delete/hide, for months now, because before the user was deleted, he sent me one message. That means that I am now stuck with "steve.houston [1]" in my list of Direct Messages. There is no way for me, through the UI, to hide that room, because the "hide room" button is where the [1] currently is. It also means I ALWAYS have a [1] on my favicon on the tabs.

SeverinDK avatar Nov 30 '17 17:11 SeverinDK

Present the issue on version 0.59.3. We have recreated a user and we noticed this issue.

cello86 avatar Dec 01 '17 12:12 cello86

@rodrigok Maybe a cleanup/verify database script would be helpfull?

maxdwit avatar Dec 11 '17 06:12 maxdwit

@rodrigok bringing this to your attention as there seems to be a continued issue and I've seen talk in the #dev channel on open.rocket.chat about this issue.

graywolf336 avatar Dec 21 '17 20:12 graywolf336

FYI: you can manually delete the affected subscription entries from the mongodb, e.g. (no guarantees):

start the mongo shell (e.g. enter your docker-mongo container and execute mongo)

  • use the rocketchat db use rocketchat
  • find entries for the given user: db.rocketchat_subscription.find( { "name" : "USERNAME_OF_THE_DELETED_USER" } )
  • if you are satisfied with your findings, delete them: db.rocketchat_subscription.deleteMany( { "name" : "USERNAME_OF_THE_DELETED_USER" } )

Edit: Unfortunatly it does not work with rocketchat clients, they seem to access another dead database entry :( Edit2: completly deleting the rocketchat+ client directory (with all local databases, etc) makes the RC+ client work again with formerly broken users

Hopefully the deletion of subscriptions will be fixed within rocketchat, as well as a 'sanitize database' function added :)

himpich avatar Jan 10 '18 17:01 himpich