Add a citus_use_snapshot function for basic distributed snapshot isolation #6489
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.
DESCRIPTION: Adds a citus_use_snapshot UDF for basic distributed snapshot isolation
This PR implements a basic form of distributed snapshot isolation in a way that's similar to citus_create_restore_point. The citus_use_snapshot UDF:
By taking the pg_dist_transaction lock, we ensure that all ongoing 2PCs have finished when we do pg_export_snapshot, so the queries in the transaction block will not see any partially committed transactions. The lock is released immediately so it only briefly interrupts multi-shard writes in their final stages of commit.
The citus_use_snapshot UDF can only be used in REPEATABLE READ (or SERIALIZABLE) mode at the start of a transaction block. Currently, multi-shard writes are not supported due to a postgres limitation:
cannot PREPARE a transaction that has exported snapshots
.Usage:
generate concurrent multi-shard updates that should leave sum at 0:
(will have some regular deadlocks)