RocketChat / RocketChat/Rocket.Chat
Performance issue when a user changed username
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 a user changes username in chat, all messages in the collection are updated. This places a heavy load on the database if there are many documents in the collection.
rocketchat_message collection size: ~88 GB, 57 million documents
CPU usage

Steps to reproduce:
For reproduce needs a lot of documents in the collection rocketchat_message and a user should have a lot of messages
- Go to profile
- change username
Expected behavior:
Chat works
Actual behavior:
Chat is not available
Server Setup Information:
- Version of Rocket.Chat Server: 3.6.3
- Operating System: Debian
- Deployment Method: Docker
- Number of Running Instances: 4
- DB Replicaset Oplog: enabled
- MongoDB Version: 4.0
Relevant logs:
Logs from DB
update rocketchat.rocketchat_message command: { q: { u._id: "kPzqtR7ahm5z5Wgtx" }, u: { $set: { u.username: "Kerry", _updatedAt: new Date(1606316642299) } }, multi: true, upsert: false } planSummary: IXSCAN { u._id: 1 } keysExamined:52516 docsExamined:52516 nMatched:52516 nModified:52516 keysInserted:105032 keysDeleted:105032 numYields:7797 locks:{ Global: { acquireCount: { r: 7798, w: 7798 } }, Database: { acquireCount: { w: 7798 }, acquireWaitCount: { w: 4 }, timeAcquiringMicros: { w: 105158 } }, Collection: { acquireCount: { w: 7798 } } } storage:{ data: { bytesRead: 3349435742, timeReadingMicros: 64408232 } } 97265ms
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the username-change path that updates the rocketchat_message collection and review the reported MongoDB update, including its index scan and multi-document write. Done means changing a username no longer makes chat unavailable or creates the reported heavy database load, but the issue does not name files or tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb
- Domain
- backend, databases, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100