pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
7+ messages / 1 participants
[nested] [flat]

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_16_STABLE

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

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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(+)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6377f705cab2f8f3e4017cd9852887906c8ac053

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4b4798e1384ce12e19a558708e66c829276cf8d7

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_14_STABLE

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

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1b4f1c6f8a6c0b764636f25e17d37d8cab7e82be

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin
@ 2023-07-04 15:31  Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2023-07-04 15:31 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

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_15_STABLE

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

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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2023-07-04 15:31 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>
2023-07-04 15:31 pgsql: Ensure that creation of an empty relfile is fsync'd at checkpoin Heikki Linnakangas <heikki.linnakangas@iki.fi>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox