From: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | wangchuanting <wangchuanting(at)huawei(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: Re: BUG #14680: startup process on standby encounter a deadlock of TwoPhaseStateLock when redo 2PC xlog |
Date: | 2017-06-11 03:24:48 |
Message-ID: | 20170611032448.f2da5epz5pnbfmmj@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2017-06-11 03:28:48 | Re: Re: BUG #14680: startup process on standby encounter a deadlock of TwoPhaseStateLock when redo 2PC xlog |
Previous Message | Alvaro Herrera | 2017-06-11 02:25:36 | Re: Re: BUG #14680: startup process on standby encounter a deadlock of TwoPhaseStateLock when redo 2PC xlog |
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2017-06-11 03:28:48 | Re: Re: BUG #14680: startup process on standby encounter a deadlock of TwoPhaseStateLock when redo 2PC xlog |
Previous Message | Alvaro Herrera | 2017-06-11 02:25:36 | Re: Re: BUG #14680: startup process on standby encounter a deadlock of TwoPhaseStateLock when redo 2PC xlog |