Re: Relation cache invalidation on replica

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Relation cache invalidation on replica
Дата
Msg-id 20160227002958.peftvmcx4dxwe244@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: Relation cache invalidation on replica  (Konstantin Knizhnik <k.knizhnik@postgrespro.ru>)
Ответы Re: Relation cache invalidation on replica  (Simon Riggs <simon@2ndQuadrant.com>)
Список pgsql-hackers
On 2016-02-26 18:05:55 +0300, Konstantin Knizhnik wrote:
> The reason of the problem is that invalidation messages are not delivered to
> replica after the end of concurrent create index.
> Invalidation messages are included in xlog as part of transaction commit
> record.
> Concurrent index create is split into three transaction, last of which is
> just performing inplace update of index tuple, marking it as valid and
> invalidating cache. But as far as this transaction is not assigned XID, no
> transaction record is created in WAL and send to replicas. As a result,
> replica doesn't receive this invalidation messages.

Ugh, that's a fairly ugly bug.


> To fix the problem it is just enough to assign XID to transaction.
> It can be done by adding GetCurrentTransactionId() call to the end of
> DefineIdnex function:

I think it'd be a better idea to always create a commit record if
there's pending invalidation messages. It looks to me that that'd be a
simple addition to RecordTransactionCommit.  Otherwise we'd end up with
something rather fragile, relying on people to recognize such
problems. E.g. Vacuum and analyze also have this problem.

Tom, everyone, do you see any reason not to go with such an approach?
Not sending invalidations we've queued up seems like it could cause
rather serious problems with HS and/or logical decoding.

Basically I'm thinking about assigning an xid
if (nrels != 0 || nmsgs != 0 || RelcacheInitFileInval)

since we really don't ever want to miss sending out WAL in those
cases. Strictly speaking we don't need an xid, but it seems rather
fragile to suddenly have commit records without one.

Andres



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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: proposal: get oldest LSN - function
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Relation cache invalidation on replica