Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating 5.4.5 to 6.1.x fails at DB error #29167

Closed
CvH opened this issue May 8, 2023 · 3 comments
Closed

updating 5.4.5 to 6.1.x fails at DB error #29167

CvH opened this issue May 8, 2023 · 3 comments

Comments

@CvH
Copy link

CvH commented May 8, 2023

After updating Rocket.Chat snaps from 5.4.x to 6.1.5/6 (there are no other versions between) the Rocket.Chat server won't start anymore.
Looks like a mongo db migrations problem ?

Issue was posted at the snap deployment too, but no feedback for weeks RocketChat/server-snap#59 RocketChat/server-snap#55.

Stopped Service for snap application rocketchat-server.rocketchat-server.
snap.rocketchat-server.rocketchat-server.service: Consumed 2.357s CPU time.
Started Service for snap application rocketchat-server.rocketchat-server.
node $SNAP/main.js
/snap/rocketchat-server/1546/programs/server/node_modules/fibers/future.js:313
						throw(ex);
						^
errorClass [Error]: [An error occurred when creating an index for collection "users: An equivalent index already exists with the same name but different options. Requested index: { v: 2, unique: true, key: { username: 1 }, name: "username_1", sparse: true }, existing index: { v: 2, unique: true, key: { username: 1 }, name: "username_1", ns: "parties.users", sparse: 1 }]
    at Collection.createIndex (packages/mongo/collection.js:801:15)
    at setupUsersCollection (packages/accounts-base/accounts_server.js:1776:9)
    at new AccountsServer (packages/accounts-base/accounts_server.js:75:5)
    at packages/accounts-base/server_main.js:7:12
    at module (packages/accounts-base/server_main.js:19:31)
    at fileEvaluate (packages/modules-runtime.js:336:7)
    at Module.require (packages/modules-runtime.js:238:14)
    at require (packages/modules-runtime.js:258:21)
    at /snap/rocketchat-server/1546/programs/server/packages/accounts-base.js:2192:15
    at /snap/rocketchat-server/1546/programs/server/packages/accounts-base.js:2199:3
    at /snap/rocketchat-server/1546/programs/server/boot.js:369:38
    at Array.forEach (<anonymous>)
    at /snap/rocketchat-server/1546/programs/server/boot.js:210:21
    at /snap/rocketchat-server/1546/programs/server/boot.js:423:7
    at Function.run (/snap/rocketchat-server/1546/programs/server/profile.js:256:14)
    at /snap/rocketchat-server/1546/programs/server/boot.js:422:13 {
  isClientSafe: true,
  error: 'An error occurred when creating an index for collection "users: An equivalent index already exists with the same name but different options. Requested index: { v: 2, unique: true, key: { username: 1 }, name: "username_1", sparse: true }, existing index: { v: 2, unique: true, key: { username: 1 }, name: "username_1", ns: "parties.users", sparse: 1 }',
  reason: undefined,
  details: undefined,
  errorType: 'Meteor.Error'
}
pkill: pidfile not valid
Try `pkill --help' for more information.
snap.rocketchat-server.rocketchat-server.service: Control process exited, code=exited, status=1/FAILURE
snap.rocketchat-server.rocketchat-server.service: Failed with result 'exit-code'.
snap.rocketchat-server.rocketchat-server.service: Consumed 2.338s CPU time.```
@Huftierchen
Copy link

Huftierchen commented May 8, 2023

We solved that by dropping some of the index in the db.

Stop Rocket Chat Service first:
sudo service snap.rocketchat-server.rocketchat-server stop
Maybe make a backup of the db
sudo snap run rocketchat-server.backupdb

Then:
Switch to mongo db console:
sudo rocketchat-server.mongo
and then switch to the rocket db (in our install it is called "parties")
use parties
After that we dropped the following indexes.
users was the first one, but after that, rocket chat was still not able to start and tried to create indexes in other tables too.

db.users.dropIndexes()
db.rocketchat_livechat_priority.dropIndexes()
db.rocketchat_apps_logs.dropIndexes()
db.rocketchat_room.dropIndexes()
db.rocketchat_message.dropIndexes()
db.rocketchat_credential_tokens.dropIndexes()

(every line is one command in the db console)
You might try them one by one until your instance is coming back, but our log had problems with all these tables.

We also had some Errors with pending user export data, so we dropped all open jobs there too:
db.rocketchat_export_operations.remove({})

Hope this helps

@CvH
Copy link
Author

CvH commented May 9, 2023

@Huftierchen tx, removing just the user index fixed it for me

Stop RC Server

systemctl stop snap.rocketchat-server.rocketchat-server.service

For Ubuntu 20.04 install Mongodb client (rocketchat-server.mongo is broken for a while)

apt install mongodb-clients

Connect to the Mongodb and remove the user index.

mongo

use parties
db.users.dropIndexes()

reboot server

reboot

Tbh no idea why there is always something manual to mess around at the db that is not solved automatically due migrations :(

@asarubbo
Copy link

I had the same issue while migrating from mongodb-4 to mongodb-5 (4.4.20 -> 5.0.16) and db.users.dropIndexes() fixed the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants