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

Incorrect order of messages in the Matrix when using concurrency in the script #22

Open
drygdryg opened this issue Jul 18, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@drygdryg
Copy link
Contributor

If the value of the CONCURRENCY_LIMIT .env variable is set to more than 1, messages in the Matrix are displayed in the wrong order (not in chronological order).
To keep the correct message order, I have to set CONCURRENCY_LIMIT=1 and pass the --sort {ts:1} argument to each mongoexport command.

@HerHde
Copy link
Collaborator

HerHde commented Jul 19, 2024

This is odd, as they should be sorted by the timestamp. Could you maybe send me the source code of two messages RC and corresponding Matrix, please?

@drygdryg
Copy link
Contributor Author

drygdryg commented Jul 23, 2024

For testing purposes, I have set up a clean instance of Rocket.Chat (version 3.18.0) and created 7 users. I wrote a script that sequentially sent messages from these users using Rocket.Chat API.

Screenshot of Rocket.Chat source room

image

After the migration, I get a broken message order.

Screenshot of migrated room in Element Desktop demonstrating a broken message order

image

I used CONCURRENCY_LIMIT=70.

The commands I used to export:

mongoexport --collection=rocketchat_message --db=rocketchat --out=rocketchat_message.json
mongoexport --collection=rocketchat_room --db=rocketchat --out=rocketchat_room.json
mongoexport --collection=users --db=rocketchat --out=users.json

Exported RC data:
mongodb-export.zip

@desto12
Copy link

desto12 commented Jul 25, 2024

I can confirm that there is issue with sorting messages by timestamp, I tried tu run 3 separate node apps with different messages.json. I think that should be handled on the matrix side :(

@HerHde HerHde added the bug Something isn't working label Jul 25, 2024
VerHde added a commit that referenced this issue Jul 25, 2024
Too many problems arose, primarily the [problems with the message order](#22). For now, this implementation is reverted.

Reviewed-on: https://git.verdigado.com/NB-Public/rocketchat2matrix/pulls/147
Co-authored-by: Henrik Hüttemann <[email protected]>
Co-committed-by: Henrik Hüttemann <[email protected]>
VerHde added a commit that referenced this issue Jul 25, 2024
Too many problems arose, primarily the [problems with the message order](#22). For now, this implementation is reverted.

Reviewed-on: https://git.verdigado.com/NB-Public/rocketchat2matrix/pulls/147
Co-authored-by: Henrik Hüttemann <[email protected]>
Co-committed-by: Henrik Hüttemann <[email protected]>
@flying-scorpio
Copy link

As explained here, sorting on the matrix server side is not done using the timestamps (which are "just" metadata).
The warning talks about a future implementation to permit server-side modifications of the ordering, but the spec discussion seems to show this is not going anywhere.

They also talk about the Gitter migration that has been done using timestamp massaging, which is exactly what this script does.

So my understanding is that we are forced to send messages in the correct sequence to have the server respect the order, and then the timestamp just makes it so that older messages are not dated to now().

@HerHde
Copy link
Collaborator

HerHde commented Jul 25, 2024

So my understanding is that we are forced to send messages in the correct sequence to have the server respect the order

So do I understand it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants