Why are we restricting exported snapshots in subtransactions?

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Why are we restricting exported snapshots in subtransactions?
Date: 2017-06-13 03:04:29
Message-ID: 20170613030429.ybqy63h2wytfzbg7@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

ExportSnapshot() has, right at the beginning, the following block:

/*
* We cannot export a snapshot from a subtransaction because there's no
* easy way for importers to verify that the same subtransaction is still
* running.
*/
if (IsSubTransaction())
ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("cannot export a snapshot from a subtransaction")));

that reasoning doesn't seem to make too much sense to me. Given that
exported snapshots don't make the exporting-transaction's changes
visible, I don't see why that restriction is needed?

As long as the exported snapshot enforces xmin to be retained, which it
does via the pairingheap, I don't understand why we'd have to enforce
that the subtransaction is still running?

I don't have any need for that capability right now, thus am not
planning to submit a patch changing this, but I'm about to apply a patch
to ExportSnapshot() to address one of the v10 open items, so I'd like to
make sure I understand the constraints.

Greetings,

Andres Freund

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-06-13 03:25:20 macOS Sierra & System Integrity Protection
Previous Message Peter Eisentraut 2017-06-13 02:57:31 Re: BUG #14699: Statement trigger and logical replication