feat: write to UUID mapper and relation tuples in one SQL transaction #1340
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.
This wraps an SQL transaction around the UUID mapper's and the relation tuple manager's write operations.
Previously, we would insert into the UUID mapping table outside the SQL transaction where we updated/inserted the relation tuples. This is now one transaction.
Beside the obvious benefit of the whole operation being atomic, this improves performance in CockroachDB global tables, where each write operation outside of a transaction takes at least the time to commit the implicit transaction (100++ ms). Inside a transaction, inserts are faster and we have to pay the commit latency only once.
I'm open suggestions on how to better cut across the abstraction layers (handler vs manager/persister) 🤷 .
Before:
After:
Note: in these traces, the
COMMIT
-equivalent of CRDB is thesql-conn-exec
before thesql-tx-commit
span.