[HACKERS] Why are we restricting exported snapshots in subtransactions? - Mailing list pgsql-hackers

From Andres Freund
Subject [HACKERS] Why are we restricting exported snapshots in subtransactions?
Date
Msg-id 20170613030429.ybqy63h2wytfzbg7@alap3.anarazel.de
Whole thread Raw
Responses Re: [HACKERS] Why are we restricting exported snapshots in subtransactions?  (Robert Haas <robertmhaas@gmail.com>)
List 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
thatthe 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



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [HACKERS] Race conditions with WAL sender PID lookups
Next
From: Robert Haas
Date:
Subject: [HACKERS] macOS Sierra & System Integrity Protection