This is probably of little importance, but it's possible in PostgreSQL to retrieve the transaction snapshot with pg_export_snapshot and restore it with set transaction to start a second transaction with the same level of visibility (see the documentation).

I'm interested to know if that works on a hot-standby or is specific to a single server? Could you export a snapshot on the standby and then use it with set transaction on the master? I doubt it.

  • Don’t think you can run pg_export_snapshot on a replica: think it needs to be run within a transaction — which you can’t do on a replica. – Colin 't Hart Jul 11 '19 at 11:54
  • @Colin'tHart I'm being sloppy with my terminology, by replica I mean hot standby, which does allow transactions: postgresql.org/docs/11/hot-standby.html – Eloff Jul 11 '19 at 13:54

I just tried it, and it is not possible, because exported snapshots are not replicated.

Snapshots are persisted in the pg_snapshots subdirectory of the data directory, and you will see that they don't show up on the standby.

| improve this answer | |
  • Thanks for testing that out! – Eloff Jul 13 '19 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.