Alvaro Herrera wrote:
For some reason I sent a preliminary version of the email I was writing.
Some additional thoughts that were supposed to be in there:
> I also agree that restoreTwoPhaseData doesn't need to hold the lock,
> since we don't expect anything running concurrently, but that it's okay
> to hold it and makes the whole thing simpler.
It's okay to hold the lock for the whole duration of the function.
> We could try to apply an equivalent rationale to
> RecoverPreparedTransactions: even though we have already been running in
> HOT standby mode for a while, there's no possibility of concurrent
> activity either: since we exited recovery, master cannot write any more
> 2PC xacts, and we haven't yet set the flag that lets open sessions write
> WAL. However, it seems mildly dangerous to run the bottom sections of
> the loop with the lock held, since it acquires other lwlocks and
> generally does a lot of crap.
Therefore, let's adopt your idea of acquiring the lock only for the
specific low-level calls that require it. But the comment atop the loop
needs a lot of work to explain why it's doing that (i.e. how come it's
reading TwoPhaseState without a lock), as in my proposed patch.
(At first, I didn't really like this very much and wanted to add more
locking to that function, but it turned quite messy, so I back-tracked).
Thanks
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs