pg_basebackup fsyncs some files despite --no-sync (was: Adding CI to our tree)

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pg_basebackup fsyncs some files despite --no-sync (was: Adding CI to our tree)
Дата
Msg-id 20220121200057.fcp7onggjhbkbu7q@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: Adding CI to our tree  (Andres Freund <andres@anarazel.de>)
Ответы Re: pg_basebackup fsyncs some files despite --no-sync (was: Adding CI to our tree)  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Hi,

On 2022-01-18 20:16:46 -0800, Andres Freund wrote:
> I noticed a few other sources of "unnecessary" fsyncs.  The most frequent
> being the durable_rename() of backup_manifest in pg_basebackup.c. Manifests are
> surprisingly large, 135k for a freshly initdb'd cluster.

Robert, I assume the fsync for manifests isn't ignoring --no-sync for a
particular reason?

The attached patch adds no-sync handling to the manifest rename, as well as
one case in the directory wal method.


It's a bit painful that we have to have code like

            if (dir_data->sync)
                r = durable_rename(tmppath, tmppath2);
            else
            {
                if (rename(tmppath, tmppath2) != 0)
                {
                    pg_log_error("could not rename file \"%s\" to \"%s\": %m",
                                 tmppath, tmppath2);
                    r = -1;
                }
            }

It seems like it'd be better to set it up so that durable_rename() could
decide internally wether to fsync, or have a wrapper around durable_rename()?


> There's an fsync in walmethods.c:tar_close() that sounds intentional, but I
> don't really understand what the comment:
> 
>     /* Always fsync on close, so the padding gets fsynced */
>     if (tar_sync(f) < 0)

tar_sync() actually checks for tar_data->sync, so it doesn't do an
fsync. Arguably the comment is a bit confusing, but ...

Greetings,

Andres Freund

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Push down time-related SQLValue functions to foreign server
Следующее
От: Greg Stark
Дата:
Сообщение: Re: Removing more vacuumlazy.c special cases, relfrozenxid optimizations