Re: [HACKERS] Issues with logical replication

Поиск
Список
Период
Сортировка
От Robert Haas
Тема Re: [HACKERS] Issues with logical replication
Дата
Msg-id CA+TgmoanD-sMvKCBi_8tqptfUnLn-4O61XQredLwFRCWGZCadg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [HACKERS] Issues with logical replication  (Stas Kelvich <s.kelvich@postgrespro.ru>)
Ответы Re: [HACKERS] Issues with logical replication
Список pgsql-hackers
On Wed, Nov 15, 2017 at 8:20 PM, Stas Kelvich <s.kelvich@postgrespro.ru> wrote:
> I did a sketch of first approach just to confirm that it solves the problem.
> But there I hold ProcArrayLock during update of flag. Since only reader is
> GetRunningTransactionData it possible to have a custom lock there. In
> this case GetRunningTransactionData will hold three locks simultaneously,
> since it already holds ProcArrayLock and XidGenLock =)

To me, it seems like SnapBuildWaitSnapshot() is fundamentally
misdesigned, and ideally Petr (who wrote the patch) or Andres (who
committed it) ought to get involved here and help fix this problem.
My own first inclination would be to rewrite this as a loop: if the
transaction ID precedes the oldest running XID, then continue; else if
TransactionIdDidCommit() || TransactionIdDidAbort() then conclude that
we don't need to wait; else XactLockTableWait() then loop.  That way,
if you hit the race condition, you'll just busy-wait instead of doing
the wrong thing.  Maybe insert a sleep(1) if we retry more than once.
That sucks, of course, but it seems like a better idea than trying to
redesign XactLockTableWait() or the procarray, which could affect an
awful lot of other things.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: Schedule for migration to pglister
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Further simplification of c.h's #include section