feat(database): introduce Snowflake IDs generator#55728
Merged
Conversation
Contributor
|
Is it additional to #55710? 🤔 |
faa65d0 to
0815707
Compare
Collaborator
Author
Not really… We discussed it at Contributor Week but I lacked time to finish so I just pushed what I had. |
ff2de9d to
c655e83
Compare
fa6578a to
a692c24
Compare
eda461b to
0a5863f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
CarlSchwan
approved these changes
Oct 23, 2025
This comment was marked as resolved.
This comment was marked as resolved.
Collaborator
Author
|
Unrelated red CI, documentation added in nextcloud/documentation#13811 |
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
Allow to get an id for the storing the preview on disk before inserting the preview on the DB. Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
skjnldsv
approved these changes
Oct 29, 2025
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce Snowflake IDs generator/decoder
See https://en.wikipedia.org/wiki/Snowflake_ID for more info
Documentation in feat: add Snowflake IDs information documentation#13811
TODO
Implementation notes
Format
Snowflake IDs use 64 bits. I chose to split them like this:
Issues with 32 bits
On 32 bits systems, 64 bits int are stored in
float.The problem is
floatare losing precision with large numbers like numbers used here so when loading a number, the sequence ID can change.So, Snowflake IDs are given as
stringfor 64 bits and 32 bits systems.Server ID
For now, take a hash of hostname. Can be improved with a mapping of server with a server ID.
Sequence ID
PHP-FPM and Apache module share memory and allow the use of
apcu_incto keep sequence ID.For CLI, fallback to random (shared cache dropped)
Decode tool
TODO
Checklist
3. to review, feature component)stable32)