- Notifications
You must be signed in to change notification settings - Fork1k
Implements distributed sequence#5583
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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
Fixes language tests
Add nextval language test
kearfy previously approved these changesApr 28, 2025
gsserge approved these changesApr 29, 2025
Merged via the queue intomain with commitApr 29, 2025
ff5061b
33 checks passed
Uh oh!
There was an error while loading.Please reload this page.
2 tasks
emmanuel-keller added a commit that referenced this pull requestMay 2, 2025
Sign up for freeto 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.
Uh oh!
There was an error while loading.Please reload this page.
Thank you for submitting this pull request. We really appreciate you spending the time to work on SurrealDB. 🚀 🎉
What is the motivation?
The implementation of distributed sequences in SurrealDB meets the critical need for generating reliable, monotonically increasing numeric identifiers across a cluster of nodes without excessive coordination overhead, allowing applications to utilize sequences for unique IDs, counters, and ordered operations with optimal performance in distributed environments.
What does this change do?
Distributed Sequence Generator for SurrealDB.
This code provides reliable, monotonically increasing numeric sequences in both single‑node and clustered SurrealDB deployments (multiple compute nodes backed by TiKV). It uses a batch‑allocation strategy to minimise coordination while guaranteeing global uniqueness.
Key features:
How it works
The sequence implementation avoids contention by having each node reserve a range of sequence values, allowing it to serve multiple requests locally without requiring distributed coordination for every request. When a node exhausts its allocated range, it acquires a new batch from the distributed store.
To create a sequence:
It is possible to modify the timeout of the sequence:
Once a sequence is created, it is possible to retrieve the consecutive values:
Will return:
To remove a sequence:
INFO FOR DB returns now defined sequences:
What is your testing strategy?
Github action.
Tests have been added to language tests and unit tests.
Is this related to any issues?
Does this change need documentation?
Have you read the Contributing Guidelines?