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

Avoid exhausting type ids due to transaction rollbacks #435

Merged
merged 4 commits into from
Jan 17, 2025

Conversation

erikrozendaal
Copy link
Member

@erikrozendaal erikrozendaal commented Dec 19, 2024

Type ids (for aggregate, command, and event types) use the SMALLINT data type to optimize storage usage. However, when a sequence is used to generated ids the ids can be dropped on transaction rollback. This can cause the ids to be quickly exhausted when something is misconfigured.

This change uses the highest id + 1 for the next id. This is slow and requires table locking, but since new types are rarely added this should not impact normal performance.

  • Add changelog and migration instructions

@erikrozendaal erikrozendaal force-pushed the avoid-exhausting-type-ids branch 3 times, most recently from 3bdf5c8 to e3e1b3e Compare January 15, 2025 14:37
Type ids (for aggregate, command, and event types) use the `SMALLINT`
data type to optimize storage usage. However, when a sequence is used
to generated ids the ids can be dropped on transaction rollback. This
can cause the ids to be quickly exhausted when something is
misconfigured.

This change uses the highest id + 1 for the next id. This is slow and
requires table locking, but since new types are rarely added this
should not impact normal performance.
Note that updating the type tables is a very rare occurence (only when
new code is deployed and the new types are committed to the event
store) so locking these tables should not be a performance bottleneck
in the normal case.
@erikrozendaal erikrozendaal force-pushed the avoid-exhausting-type-ids branch from e3e1b3e to 217e61d Compare January 17, 2025 12:44
@erikrozendaal erikrozendaal merged commit 6db3b3a into master Jan 17, 2025
7 checks passed
@erikrozendaal erikrozendaal deleted the avoid-exhausting-type-ids branch January 17, 2025 15:27
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

Successfully merging this pull request may close these issues.

2 participants