pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
Дата
Msg-id E1qGi03-001tAd-H6@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Ensure that creation of an empty relfile is fsync'd at checkpoint.

If you create a table and don't insert any data into it, the relation file
is never fsync'd. You don't lose data, because an empty table doesn't have
any data to begin with, but if you crash and lose the file, subsequent
operations on the table will fail with "could not open file" error.

To fix, register an fsync request in mdcreate(), like we do for mdwrite().

Per discussion, we probably should also fsync the containing directory
after creating a new file. But that's a separate and much wider issue.

Backpatch to all supported versions.

Reviewed-by: Andres Freund, Thomas Munro
Discussion: https://www.postgresql.org/message-id/d47d8122-415e-425c-d0a2-e0160829702d%40iki.fi

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/acc8cdff424529ce34e93a7ae51eb410b02c7b30

Modified Files
--------------
src/backend/storage/smgr/md.c | 3 +++
1 file changed, 3 insertions(+)


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Remove incidental md5() function uses from several tests
Следующее
От: Daniel Gustafsson
Дата:
Сообщение: pgsql: Fix assertion failure in snapshot building