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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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 2 times, most recently from daf7b05 to 3bdf5c8 Compare January 15, 2025 14:20
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 3bdf5c8 to e3e1b3e Compare January 15, 2025 14:37
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