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

[FIX] Messages was grouping wrong some times when server is slow #10472

Merged
merged 4 commits into from
Apr 17, 2018

Conversation

gdelavald
Copy link
Contributor

@gdelavald gdelavald commented Apr 16, 2018

Closes #9926

Tested locally with @geekgonecrazy's script for load testing and this seems to fix most of the issues.

Reproducing while offline (Messages on the right are grouped with the wrong user)
image

After fix:
image
Even though the timestamp is not respected, the messages are grouped correctly.

@engelgabriel engelgabriel temporarily deployed to rocket-chat-pr-10472 April 16, 2018 20:39 Inactive
karlprieb
karlprieb previously approved these changes Apr 16, 2018
@karlprieb karlprieb added this to the 0.64.0 milestone Apr 16, 2018
@gdelavald gdelavald changed the title [FIX] Fix wrong grouping on messages when server is slow [WIP] Fix wrong grouping on messages when server is slow Apr 16, 2018
@gdelavald gdelavald temporarily deployed to rocket-chat-pr-10472 April 16, 2018 22:05 Inactive
@gdelavald gdelavald temporarily deployed to rocket-chat-pr-10472 April 16, 2018 22:22 Inactive
@gdelavald gdelavald changed the title [WIP] Fix wrong grouping on messages when server is slow [FIX] Fix wrong grouping on messages when server is slow Apr 16, 2018
@gdelavald gdelavald temporarily deployed to rocket-chat-pr-10472 April 16, 2018 22:51 Inactive
@geekgonecrazy
Copy link
Contributor

You da man! That's been haunting us for a while now 😁

@rodrigok rodrigok changed the title [FIX] Fix wrong grouping on messages when server is slow [FIX] Messages was grouping wrong some times when server is slow Apr 17, 2018
@rodrigok rodrigok merged commit cb34777 into develop Apr 17, 2018
@rodrigok rodrigok deleted the fix-grouping-on-slow-server branch April 17, 2018 17:37
@@ -223,7 +223,7 @@ const RoomManager = new function() {
};

const loadMissedMessages = function(rid) {
const lastMessage = ChatMessage.findOne({rid}, {sort: {ts: -1}, limit: 1});
const lastMessage = ChatMessage.findOne({rid, temp: { $exists: false } }, {sort: {ts: -1}, limit: 1});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing!

@@ -339,7 +339,19 @@ Template.message.onViewRendered = function(context) {
return this._domrange.onAttached(function(domRange) {
const currentNode = domRange.lastNode();
const currentDataset = currentNode.dataset;
const previousNode = currentNode.previousElementSibling;
const getPreviousSentMessage = (currentNode) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My biggest concern here is performance. If we are creating a new function for every message, then I can imagine the memory level just went up a little bit more...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, can we have some monitoring on unstable and develop when this hits? @geekgonecrazy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@graywolf336 do you think simply moving the function to outer scope would help?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure about that, as I don't know if it would be created everytime the template is initialized. That would be something to test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how garbage collector works for these lambda functions used/created on closed contexts.. if that is a real problem or not..

what I know is moving it to file's root scope will define it once and will not run every time the template is initialized.

@rodrigok rodrigok mentioned this pull request Apr 28, 2018
@ggazzo ggazzo mentioned this pull request Aug 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] When server is slow, if I send a message it appears like the other users sent it
7 participants