Re: Speedup of relation deletes during recovery

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Speedup of relation deletes during recovery
Дата
Msg-id 20180615174504.cf2ba4p6xuu36hn6@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: Speedup of relation deletes during recovery  (Fujii Masao <masao.fujii@gmail.com>)
Ответы Re: Speedup of relation deletes during recovery  (Teodor Sigaev <teodor@sigaev.ru>)
Re: Speedup of relation deletes during recovery  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Hi,

We just had a customer hit this issue. I kind of wonder whether this
shouldn't be backpatched: Currently the execution on the primary is
O(NBuffers * log(ndrels)) whereas it's O(NBuffers * ndrels) on the
standby - with a lot higher constants to boot.  That means it's very
easy to get into situations where the standy starts to lag behind very significantly.

> --- a/src/backend/access/transam/twophase.c
> +++ b/src/backend/access/transam/twophase.c
> @@ -1445,6 +1445,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
>      int            ndelrels;
>      SharedInvalidationMessage *invalmsgs;
>      int            i;
> +    SMgrRelation *srels = NULL;
>  
>      /*
>       * Validate the GID, and lock the GXACT to ensure that two backends do not
> @@ -1534,13 +1535,16 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
>          delrels = abortrels;
>          ndelrels = hdr->nabortrels;
>      }
> +
> +    srels = palloc(sizeof(SMgrRelation) * ndelrels);
>      for (i = 0; i < ndelrels; i++)
> -    {
> -        SMgrRelation srel = smgropen(delrels[i], InvalidBackendId);
> +        srels[i] = smgropen(delrels[i], InvalidBackendId);
>  
> -        smgrdounlink(srel, false);
> -        smgrclose(srel);
> -    }
> +    smgrdounlinkall(srels, ndelrels, false);
> +
> +    for (i = 0; i < ndelrels; i++)
> +        smgrclose(srels[i]);
> +    pfree(srels);

This code is now duplicated three times - shouldn't we just add a
function that encapsulates dropping relations in a commit/abort record?

Greetings,

Andres Freund


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: Speedup of relation deletes during recovery