8000 WAL-log the creation of the init fork of unlogged indexes. · postgres/postgres@988719b · GitHub
[go: up one dir, main page]

Skip to content

Commit 988719b

Browse files
committed
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
1 parent 2316ff1 commit 988719b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/backend/catalog/index.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "catalog/pg_trigger.h"
5050
#include "catalog/pg_type.h"
5151
#include "catalog/storage.h"
52+
#include "catalog/storage_xlog.h"
5253
#include "commands/tablecmds.h"
5354
#include "commands/event_trigger.h"
5455
#include "commands/trigger.h"
@@ -2427,6 +2428,7 @@ index_build(Relation heapRelation,
24272428
!smgrexists(RelationGetSmgr(indexRelation), INIT_FORKNUM))
24282429
{
24292430
smgrcreate(RelationGetSmgr(indexRelation), INIT_FORKNUM, false);
2431+
log_smgrcreate(&indexRelation->rd_node, INIT_FORKNUM);
24302432
indexRelation->rd_amroutine->ambuildempty(indexRelation);
24312433
}
24322434

0 commit comments

Comments
 (0)
0