Re: Avoid memory leaks during base backups

Поиск
Список
Период
Сортировка
От Bharath Rupireddy
Тема Re: Avoid memory leaks during base backups
Дата
Msg-id CALj2ACU6XzTv7vxZytGVdvc-fJuRF8-xL7=od8_rz6+TL3xwFg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Avoid memory leaks during base backups  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Avoid memory leaks during base backups  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Wed, Sep 28, 2022 at 8:46 PM Robert Haas <robertmhaas@gmail.com> wrote:
>
> I feel like we ought to be trying to tie
> the cleanup into WalSndErrorCleanup() or WalSndResourceCleanup() based
> on having the memory context that we ought to be blowing away stored
> in a global variable, rather than using a try/catch block.

Okay, I got rid of the try-catch block. I added two clean up callbacks
(one for SQL backup functions or on-line backup, another for base
backup) that basically delete the respective memory contexts and reset
the file-level variables, they get called from PostgresMain()'s error
handling code.

> Like, maybe there's a function EstablishWalSenderMemoryContext() that
> commands can call before allocating memory that shouldn't survive an
> error. And it's deleted after each command if it exists, or if an
> error occurs then WalSndErrorCleanup() deletes it.

I don't think we need any of the above. I've used file-level variables
to hold memory contexts, allocating them whenever needed and cleaning
them up either at the end of backup operation or upon error.

Please review the attached v3 patch.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Вложения

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

Предыдущее
От: Aleksander Alekseev
Дата:
Сообщение: Re: Refactor UnpinBuffer()
Следующее
От: Bharath Rupireddy
Дата:
Сообщение: Re: Refactor UnpinBuffer()