RocketChat / RocketChat/Rocket.Chat

Error on creating index

Open
#20,699 3 comments 0 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:

When updating Rocket.Chat to 3.11.x, the following error occurred.

This happens by using normal user of mongodb

e.g.

db.createUser(
{
  user: "rocketchat",
  pwd: "password",
  roles:
  [
    { role: "dbAdmin", db: "rocketchat" },
    { role: "readWrite", db: "rocketchat" },
    { role: "dbAdmin", db: "local" },
    { role: "readWrite", db: "local" },
  ]
}
)

When giving admin privilege to rocket chat user, Rocket.Chat run normally.

e.g.

db.createUser(
{
  user: "rocketchat",
  pwd: "password",
  roles: [
    { role: "userAdminAnyDatabase", db: "admin" }, "root"
  ]
}
)

Could you tell me a smart way to fix this issue?

Steps to reproduce:
  1. Download and install 3.11.1
  2. Start Rocket.Chat
Expected behavior:

Run normally.

Actual behavior:

Aborted.

Server Setup Information:
  • Version of Rocket.Chat Server: 3.11.x
  • Operating System: Debian 10.8
  • Deployment Method: tar
  • Number of Running Instances: 1
  • NodeJS Version: 12.20.1
  • MongoDB Version: 6.14.10
Additional context
Relevant logs:
Feb 11 02:23:57 n13 systemd[1]: Started The Rocket.Chat server.
Feb 11 02:24:04 n13 rocketchat[7480]: Change Stream is available for your installation, give admin permissions to your database user to use this improved version.
Feb 11 02:30:09 n13 rocketchat[7480]: Error creating index: email_inbox -> { email: 1 } { unique: true } MongoError: not authorized on rocketchat to execute command { insert: "system.indexes", documents: [ { ns: "rocketchat.rocketchat_email_inbox", key: { email: 1 }, name: "email_1", unique: true } ], ordered: true, lsid: { id: UUID("505bdafd-c81a-4261-a571-97cb31671f5d") }, $clusterTime: { clusterTime: Timestamp(1613039406, 1), signature: { hash: BinData(0, 9D05D1D9C646A81617FF556E3C78753857559FDE), keyId: 6917603678467653635 } }, $db: "rocketchat" }
Feb 11 02:30:09 n13 rocketchat[7480]:     at Connection.<anonymous> (/srv/Rocket.Chat/bundle-3.11.1/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:451:61)
Feb 11 02:30:09 n13 rocketchat[7480]:     at Connection.emit (events.js:314:20)
Feb 11 02:30:09 n13 rocketchat[7480]:     at Connection.EventEmitter.emit (domain.js:483:12)
Feb 11 02:30:09 n13 rocketchat[7480]:     at processMessage (/srv/Rocket.Chat/bundle-3.11.1/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:452:10)
Feb 11 02:30:09 n13 rocketchat[7480]:     at Socket.<anonymous> (/srv/Rocket.Chat/bundle-3.11.1/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:621:15)
Feb 11 02:30:09 n13 rocketchat[7480]:     at Socket.emit (events.js:314:20)
Feb 11 02:30:09 n13 rocketchat[7480]:     at Socket.EventEmitter.emit (domain.js:483:12)
Feb 11 02:30:09 n13 rocketchat[7480]:     at addChunk (_stream_readable.js:297:12)
Feb 11 02:30:09 n13 rocketchat[7480]:     at readableAddChunk (_stream_readable.js:272:9)
Feb 11 02:30:09 n13 rocketchat[7480]:     at Socket.Readable.push (_stream_readable.js:213:10)
Feb 11 02:30:09 n13 rocketchat[7480]:     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Feb 11 02:30:09 n13 rocketchat[7480]:     at TCP.callbackTrampoline (internal/async_hooks.js:126:14) {
Feb 11 02:30:09 n13 rocketchat[7480]:   operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1613039406 },
Feb 11 02:30:09 n13 rocketchat[7480]:   ok: 0,
Feb 11 02:30:09 n13 rocketchat[7480]:   code: 13,
Feb 11 02:30:09 n13 rocketchat[7480]:   codeName: 'Unauthorized',
Feb 11 02:30:09 n13 rocketchat[7480]:   '$clusterTime': {
Feb 11 02:30:09 n13 rocketchat[7480]:     clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1613039406 },
Feb 11 02:30:09 n13 rocketchat[7480]:     signature: { hash: [Binary], keyId: [Long] }
Feb 11 02:30:09 n13 rocketchat[7480]:   }
Feb 11 02:30:09 n13 rocketchat[7480]: }

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

Start with the reported MongoDB authorization error for creating the email_inbox index and compare the listed database roles with the command Rocket.Chat performs. The work is done when Rocket.Chat 3.11.x starts normally with the stated non-admin user and no unauthorized index-creation error appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.