mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Support synchronization of snapshots through an export/import procedure.
A transaction can export a snapshot with pg_export_snapshot(), and then others can import it with SET TRANSACTION SNAPSHOT. The data does not leave the server so there are not security issues. A snapshot can only be imported while the exporting transaction is still running, and there are some other restrictions. I'm not totally convinced that we've covered all the bases for SSI (true serializable) mode, but it works fine for lesser isolation modes. Joachim Wieland, reviewed by Marko Tiikkaja, and rather heavily modified by Tom Lane
This commit is contained in:
@ -2067,6 +2067,16 @@ PrepareTransaction(void)
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot PREPARE a transaction that has operated on temporary tables")));
|
||||
|
||||
/*
|
||||
* Likewise, don't allow PREPARE after pg_export_snapshot. This could be
|
||||
* supported if we added cleanup logic to twophase.c, but for now it
|
||||
* doesn't seem worth the trouble.
|
||||
*/
|
||||
if (XactHasExportedSnapshots())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot PREPARE a transaction that has exported snapshots")));
|
||||
|
||||
/* Prevent cancel/die interrupt while cleaning up */
|
||||
HOLD_INTERRUPTS();
|
||||
|
||||
|
Reference in New Issue
Block a user