RocketChat / RocketChat/Rocket.Chat

Duplicate key error when trying to log in with GitHub connected account after recent database migration

Open
#11,326 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

Description:

It looks like snap triggered a database migration (but not an application update) on our chat server this morning:

screen shot 2018-07-03 at 1 29 49 pm

I found that I had been automatically logged out this morning, most likely because of this migration. I had been logged in via OAuth with my connected Github account. When I try to log back in with the same account using the Github integration, I get a generic "Internal server error" message.

When I check the logs using a separate, non-OAuth account, I can see this error being generated when I try to log in:

Exception while invoking method 'login' MongoError: E11000 duplicate key error collection: parties.users index: services.github.id_1 dup key: { : 5004534 }     at Function.MongoError.create (/snap/rocketchat-server/1273/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/error.js:31:11)     at toError (/snap/rocketchat-server/1273/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/utils.js:139:22)     at /snap/rocketchat-server/1273/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/collection.js:1059:67     at /snap/rocketchat-server/1273/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:469:18     at _combinedTickCallback (internal/process/next_tick.js:131:7)     at process._tickDomainCallback (internal/process/next_tick.js:218:9)

It appears that it is trying to create a duplicate record on a unique key - is it trying to recreate the record for my OAuth account, instead of finding the one that already exists?

Server Setup Information:
  • Version of Rocket.Chat Server: 0.65.1
  • Operating System: Ubuntu
  • Deployment Method: snap
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Enabled
  • NodeJS Version: v8.11.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The reported entry point is the login method for the GitHub integration; start by tracing how the existing services.github.id_1 MongoDB unique index is handled during OAuth login. Reproduce the failure on Rocket.Chat 0.65.1 with the listed snap/Ubuntu setup and verify that an already connected account can log in without the duplicate-key error.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, mongodb
Domain
authentication, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.