BufferedEvents Compound Primary Key #568
Merged
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.
What Changed?
Move the auto-increment Id for BufferedEvents below the primary key to make this a bit more explicit of the true ordering necessary. This is not necessary for Vitess but should make any future alterations here easier by physically clustering records together that are part of the same runId. Additionally, the true solution is to use the nextEventId in the database, but this is not currently guaranteed to be unique, so nesting the auto-incrementing Id should make a key change to an application specified id simpler in the future.
Re: Vitess - This should not require a Vitess sequences table as the VIndex that should be used by Vitess here (shard_id) will does not use the AutoIncrement table and we are okay with local ordering for each MySQL instance.
Risks?
No major risks as application code changes are not required as the application currently uses
(shard_id, namespace_id, workflow_id, run_id)as the lookup key. This should see some read performance increases by reducing fragmentation on the read path. Write performance could theoretically suffer slightly in a non-sharded MySQL setup. Will watch our stress tests for any changes.