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

Special UUIDv7 function for microservices #103

Open
sergeyprokhorenko opened this issue Aug 24, 2024 · 1 comment
Open

Special UUIDv7 function for microservices #103

sergeyprokhorenko opened this issue Aug 24, 2024 · 1 comment

Comments

@sergeyprokhorenko
Copy link

Although fault tolerance requires that each microservice writes to its own database tables, in practice this requirement is often violated.

The implementation of UUIDv7 for PostgreSQL had to switch from Method 1 to Method 3 (Increased Clock Precision with 12 bits sub-millisecond timestamp fraction) to synchronize the UUIDv7s generated by different microservices for the same database table. This turned out to be simpler than the autoincrement-like analogue. See the C implementation v27-0001-Implement-UUID-v7.patch of Method 3 at the page as a reference. The entire timestamp acts as a counter in rare case when more than about 4 identifiers per microsecond are generated.

This implementation also added the ability to offset the timestamp by a specified interval to hide the record creation time for information security. If offset would cause the timestamp to be outside the allowed range, it should not be applied.

It would be nice to add such a special UUIDv7 function for microservices.

@fabiolimace
Copy link
Member

fabiolimace commented Sep 7, 2024

Hi @sergeyprokhorenko!

I am aware of UUIDv7 for PostgreSQL. I believe it will be a reference for other implementations when it is released.

However, we have to take into account the time resolution available at runtime. Java 8 is limited to millisecond resolution, while this is not an issue with newer versions of Java. So a way to detect the time resolution at runtime is needed.

For now, I think it is better to wait for the release of UUIDv7 for PostgreSQL. It is unlikely that it will be changed, but it's always good to be patient. So I will wait a little longer.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants