diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2023-07-06 17:25:29 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2023-07-06 17:29:13 +0300 |
commit | 32f327f681d5ea86582c50e3eaf8f52a9ee65754 (patch) | |
tree | 48d5de593a72bb2b9f81cf5e7a2d47a1bf80a87f /src | |
parent | cf3e29851278e18b7b4997cd0bd90edb372c69da (diff) | |
download | postgresql-32f327f681d5ea86582c50e3eaf8f52a9ee65754.tar.gz postgresql-32f327f681d5ea86582c50e3eaf8f52a9ee65754.zip |
WAL-log the creation of the init fork of unlogged indexes.
We create a file, so we better WAL-log it. In practice, all the
built-in index AMs and all extensions that I'm aware of write a
metapage to the init fork, which is WAL-logged, and replay of the
metapage implicitly creates the fork too. But if ambuildempty() didn't
write any page, we would miss it.
This can be seen with dummy_index_am. Set up replication, create a
'dummy_index_am' index on an unlogged table, and look at the files
created in the replica: the init fork is not created on the
replica. Dummy_index_am doesn't do anything with the relation files,
however, so it doesn't lead to any user-visible errors.
Backpatch to all supported versions.
Reviewed-by: Robert Haas
Discussion: https://www.postgresql.org/message-id/6e5bbc08-cdfc-b2b3-9e23-1a914b9850a9%40iki.fi
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/index.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index ada0c880570..c9c0b23a1ea 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -54,6 +54,7 @@ #include "catalog/pg_trigger.h" #include "catalog/pg_type.h" #include "catalog/storage.h" +#include "catalog/storage_xlog.h" #include "commands/event_trigger.h" #include "commands/progress.h" #include "commands/tablecmds.h" @@ -3024,6 +3025,7 @@ index_build(Relation heapRelation, !smgrexists(RelationGetSmgr(indexRelation), INIT_FORKNUM)) { smgrcreate(RelationGetSmgr(indexRelation), INIT_FORKNUM, false); + log_smgrcreate(&indexRelation->rd_node, INIT_FORKNUM); indexRelation->rd_indam->ambuildempty(indexRelation); } |