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

Repair UUIDs duplicates (storage 3.1 upgrade) #143

Merged
merged 11 commits into from
Apr 9, 2024
Merged

Conversation

Athozus
Copy link
Member

@Athozus Athozus commented Apr 1, 2024

This is a proposal for the most important hotfix of this release. What does it do ?

  • It first checks, when giving an UUID, if it is not already used in the database ;
  • At the startup, in after migrating in migrate.lua, it checks for non-duplicates, and if there are, it gives new ID to all messages that are not the same (mail.are_message_sames()). Of course, because it iterates through all messages, after fixing message1, it checks message2, so if there is a message3 also concerned by the duplicate, it is fixed in the message2 loop.

I tested it with 10 000 messages, it runs quite good (no performance loss). If you want to test it, you can use the /mail_spam command written in #103.

Of course, performance can still be improved, but that's not really a mess here.

I ping @Bastrabun because he was the first who noticed the issue on Your Land.

Fix #122, #126.

@Athozus Athozus added Bug Something isn't working Performance Related to performance improvement (lag issues) Release blocker No release until this is closed labels Apr 1, 2024
@Athozus Athozus added this to the 1.4.0 milestone Apr 1, 2024
@Athozus Athozus linked an issue Apr 1, 2024 that may be closed by this pull request
@Athozus Athozus changed the title Id check repair Check and repair UUIDs Apr 1, 2024
@BuckarooBanzay
Copy link
Member

did i read this correctly: the "repair" code runs on every startup, right?

and: are you sure this is needed, uuid collisions should be borderline impossible :/

@S-S-X
Copy link
Member

S-S-X commented Apr 2, 2024

Could you @Athozus or @Bastrabun reveal what is the issue with current RNG or implementation? And if there's issues with RNG on Your Land could it be that RNG is compromised by one of the mods?

It is true that it is easy to trash math.random, if that's the issue then better solution would be to use Minetest's own RNG API like PcgRandom which you could, if you feel paranoid, initialize with SecureRandom.

util/uuid.lua Outdated Show resolved Hide resolved
@Athozus
Copy link
Member Author

Athozus commented Apr 2, 2024

The issue was fixed in #137. However, « contaminated » databases were already infected.

So it is repairing that duplicates caused by the bug fixed in #137.

Maybe, it should not be run at every startup, but like when passed into a command ? Like /mail_repair, only available for admins ?

@S-S-X
Copy link
Member

S-S-X commented Apr 2, 2024

Maybe, it should not be run at every startup, but like when passed into a command ?

If it is to fix duplicates caused by now fixed bug then you could just automatically run it once and then increment database version to v3.1 or v4 depending on which number you like most / if you want to use some versioning scheme that differentiates breaking changes from bug fixes and feature additions.

@Athozus
Copy link
Member Author

Athozus commented Apr 2, 2024

v3.1 is a good way to do it, indeed.

@Athozus
Copy link
Member Author

Athozus commented Apr 2, 2024

Applied your suggestions 👍

@Athozus
Copy link
Member Author

Athozus commented Apr 2, 2024

docker-compose command-not-found in the checks. Without that error, they all have succeed. I don't understand how to fix this.

util/uuid.lua Outdated Show resolved Hide resolved
@S-S-X
Copy link
Member

S-S-X commented Apr 2, 2024

docker-compose command-not-found in the checks. Without that error, they all have succeed. I don't understand how to fix this.

I guess it is issue with action runner, not mail mod. @BuckarooBanzay might have idea.

@BuckarooBanzay
Copy link
Member

BuckarooBanzay commented Apr 4, 2024

docker-compose command-not-found in the checks

had that somewhere else yesterday too, seems like a github issue, just ignore it :)

@Bastrabun could please elaborate on the uuid/rng-issue, i'm curious how something like this would happen 🤔

@Athozus
Copy link
Member Author

Athozus commented Apr 4, 2024

docker-compose command-not-found in the checks

had that somewhere else yesterday too, seems like a github issue, just ignore it :)

I ran it, it was fixed, thanks !

The risk is ridiculous compared to the performance lost, even for several millions of messages.
@Athozus Athozus changed the title Check and repair UUIDs Repair UUIDs duplicates (storage 3.1 upgrade) Apr 4, 2024
@Athozus Athozus requested review from S-S-X and BuckarooBanzay April 4, 2024 13:08
@Athozus
Copy link
Member Author

Athozus commented Apr 4, 2024

Applied you suggestions in latest commit c052e59. Sounds ready to merge (I requested a review anyway).

So now it focuses only on migrate.lua, it no longer checks for a chance over millions (if not billions) of duplicate.

The risk was of 1 over 1630.12 = 1,6.1037. Minetest servers can be very popular, but 😁

@Athozus
Copy link
Member Author

Athozus commented Apr 4, 2024

@Bastrabun could please elaborate on the uuid/rng-issue, i'm curious how something like this would happen 🤔

Btw, it was not an error from RNG, it was due to the bug fixed in #137, which use the selected message id into compose.lua, so for a new message.

Copy link
Member

@BuckarooBanzay BuckarooBanzay left a comment

Choose a reason for hiding this comment

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

code looks sane-ish, didn't have time to test though :/

migrate.lua Outdated Show resolved Hide resolved
migrate.lua Outdated Show resolved Hide resolved
util/uuid.lua Outdated Show resolved Hide resolved
Copy link
Member

@S-S-X S-S-X left a comment

Choose a reason for hiding this comment

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

Minor suggestions for migrate.lua, don't really care if these get applied or not.

util/uuid.lua however should be just reverted to master branch as it has not been changed other than whitespace.

Drop uuid.lua from changeset and fine for me then.

@Athozus Athozus requested a review from S-S-X April 5, 2024 21:04
Copy link
Member

@S-S-X S-S-X left a comment

Choose a reason for hiding this comment

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

Seems fine, didn't test however.

@Athozus Athozus requested a review from BuckarooBanzay April 6, 2024 07:52
@Athozus Athozus added the Help wanted Extra attention is needed label Apr 6, 2024
@Athozus
Copy link
Member Author

Athozus commented Apr 6, 2024

Note that it is still upgrading to 3.1, I didn't changed that. It is an important PR so I prefer to remind you, as it was discussed a lot on our servers.

@Athozus Athozus merged commit a3af9ee into master Apr 9, 2024
20 checks passed
@Athozus Athozus removed the Help wanted Extra attention is needed label Apr 11, 2024
@Athozus Athozus deleted the id-check-repair branch April 15, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Performance Related to performance improvement (lag issues) Release blocker No release until this is closed
Projects
None yet
3 participants