Skip to content

Commit cc58418

Browse files
committed
pg_upgrade: remove pg_multixact files left by initdb
This fixes a bug that caused vacuum to fail when the '0000' files left by initdb were accessed as part of vacuum's cleanup of old pg_multixact files. Backpatch through 9.3
1 parent 2a7512b commit cc58418

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

contrib/pg_upgrade/pg_upgrade.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,35 @@ create_new_objects(void)
364364
}
365365

366366
/*
367-
* Delete the given subdirectory contents from the new cluster, and copy the
368-
* files from the old cluster into it.
367+
* Delete the given subdirectory contents from the new cluster
369368
*/
370369
static void
371-
copy_subdir_files(char *subdir)
370+
remove_new_subdir(char *subdir, bool rmtopdir)
372371
{
373-
char old_path[MAXPGPATH];
374372
char new_path[MAXPGPATH];
375373

376374
prep_status("Deleting files from new %s", subdir);
377375

378-
snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, subdir);
379376
snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
380-
if (!rmtree(new_path, true))
377+
if (!rmtree(new_path, rmtopdir))
381378
pg_log(PG_FATAL, "could not delete directory \"%s\"\n", new_path);
379+
382380
check_ok();
381+
}
382+
383+
/*
384+
* Copy the files from the old cluster into it
385+
*/
386+
static void
387+
copy_subdir_files(char *subdir)
388+
{
389+
char old_path[MAXPGPATH];
390+
char new_path[MAXPGPATH];
391+
392+
remove_new_subdir(subdir, true);
393+
394+
snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, subdir);
395+
snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
383396

384397
prep_status("Copying old %s to new server", subdir);
385398

@@ -420,6 +433,7 @@ copy_clog_xlog_xid(void)
420433
{
421434
copy_subdir_files("pg_multixact/offsets");
422435
copy_subdir_files("pg_multixact/members");
436+
423437
prep_status("Setting next multixact ID and offset for new cluster");
424438

425439
/*
@@ -437,6 +451,13 @@ copy_clog_xlog_xid(void)
437451
}
438452
else if (new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
439453
{
454+
/*
455+
* Remove files created by initdb that no longer match the
456+
* new multi-xid value.
457+
*/
458+
remove_new_subdir("pg_multixact/offsets", false);
459+
remove_new_subdir("pg_multixact/members", false);
460+
440461
prep_status("Setting oldest multixact ID on new cluster");
441462

442463
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy