Re: Relation cache invalidation on replica

Поиск
Список
Период
Сортировка
От Simon Riggs
Тема Re: Relation cache invalidation on replica
Дата
Msg-id CANP8+jLBdAopmx-GRkmooa1=pNM3Nh=ymCEFRWjZTiKxLeJJmg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Relation cache invalidation on replica  (Andres Freund <andres@anarazel.de>)
Ответы Re: Relation cache invalidation on replica  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On 27 February 2016 at 01:23, Andres Freund <andres@anarazel.de> wrote:
On 2016-02-27 01:16:34 +0000, Simon Riggs wrote:
> If the above is true, then the proposed fix wouldn't work either.
>
> No point in sending a cache invalidation message on the standby if you
> haven't also written WAL, since the catalog re-read would just see the old
> row.
>
> heap_inplace_update() does write WAL, which blows away the starting premise.

I'm not following here. heap_inplace_update() indeed writes WAL, but it
does *NOT* (and may not) assign an xid. Thus we're not emitting the
relcache invalidation queued in DefineIndex(), as
RecordTransactionCommit() currently skips emitting a commit record if
there's no xid.

OK.

Surely then the fix is to make heap_inplace_update() assign an xid? That way any catalog change will always generate a commit record containing the invalidation that goes with the change. No need to fix up the breakage later.

The other heap_insert|update|delete functions (and similar) all assign xid, so it is consistent for us to do that for inplace_update also.


diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index f443742..94282a0 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -6022,6 +6022,7 @@ heap_abort_speculative(Relation relation, HeapTuple tuple)
 void
 heap_inplace_update(Relation relation, HeapTuple tuple)
 {
+       TransactionId xid = GetCurrentTransactionId();
        Buffer          buffer;
        Page            page;
        OffsetNumber offnum;

--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Вложения

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

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: Relation cache invalidation on replica
Следующее
От: Vitaly Burovoy
Дата:
Сообщение: Re: [PATH] Correct negative/zero year in to_date/to_timestamp