RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.42k stars 10.52k forks source link

Error on creating index #20699

Open mzch opened 3 years ago

mzch commented 3 years ago

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:

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]: }
pcmourya commented 3 years ago

May I work on this issue?

tsteiner commented 3 years ago

I think I'm running into this issue as well. I can run 3.10.6 just fine, but when I try to run 3.11.x, the process runs, but never listens on port 3000. A few minutes after startup, I see a similar error message:

Mar  2 11:35:23 <redacted> systemd[1467]: Started The Rocket.Chat server.
Mar  2 11:35:26 <redacted> rocketchat[304408]: Change Stream is available for your installation, give admin permissions to your database user to use this improved version.
Mar  2 11:41:35 <redacted> rocketchat[304408]: Error creating index: rocketchat_room -> { 'v.token': 1, 'email.thread': 1 } { sparse: true } MongoError: not authorized on rocketchat to execute command { insert: "system.indexes", documents: [ { ns: "rocketchat.rocketchat_room", key: { v.token: 1, email.thread: 1 }, name: "v.token_1_email.thread_1", sparse: true, unique: false } ], ordered: true, lsid: { id: UUID("87934e85-7d61-4542-bc3f-e794d80437e6") }, $clusterTime: { clusterTime: Timestamp(1614706894, 1), signature: { hash: BinData(0, 2C177BD53DD928E31BC8C6F657CFC743FEB9F577), keyId: 6897359607815995397 } }, $db: "rocketchat" }
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Connection.<anonymous> (/opt/rocket.chat/3.11.0/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/pool.js:451:61)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Connection.emit (events.js:314:20)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Connection.EventEmitter.emit (domain.js:483:12)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at processMessage (/opt/rocket.chat/3.11.0/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:452:10)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Socket.<anonymous> (/opt/rocket.chat/3.11.0/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/connection/connection.js:621:15)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Socket.emit (events.js:314:20)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Socket.EventEmitter.emit (domain.js:483:12)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at addChunk (_stream_readable.js:297:12)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at readableAddChunk (_stream_readable.js:272:9)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at Socket.Readable.push (_stream_readable.js:213:10)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
Mar  2 11:41:35 <redacted> rocketchat[304408]:    at TCP.callbackTrampoline (internal/async_hooks.js:126:14) {
Mar  2 11:41:35 <redacted> rocketchat[304408]:  operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1614706894 },
Mar  2 11:41:35 <redacted> rocketchat[304408]:  ok: 0,
Mar  2 11:41:35 <redacted> rocketchat[304408]:  code: 13,
Mar  2 11:41:35 <redacted> rocketchat[304408]:  codeName: 'Unauthorized',
Mar  2 11:41:35 <redacted> rocketchat[304408]:  '$clusterTime': {
Mar  2 11:41:35 <redacted> rocketchat[304408]:    clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1614706894 },
Mar  2 11:41:35 <redacted> rocketchat[304408]:    signature: { hash: [Binary], keyId: [Long] }
Mar  2 11:41:35 <redacted> rocketchat[304408]:  }
Mar  2 11:41:35 <redacted> rocketchat[304408]: }

Server Setup Information:

tsteiner commented 3 years ago

Update: this error seems to have gone away after I updated to NodeJS 12.21.0