Skip to content

Commit 0f74827

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 a87a7dc commit 0f74827

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
@@ -363,22 +363,35 @@ create_new_objects(void)
363363
}
364364

365365
/*
366-
* Delete the given subdirectory contents from the new cluster, and copy the
367-
* files from the old cluster into it.
366+
* Delete the given subdirectory contents from the new cluster
368367
*/
369368
static void
370-
copy_subdir_files(char *subdir)
369+
remove_new_subdir(char *subdir, bool rmtopdir)
371370
{
372-
char old_path[MAXPGPATH];
373371
char new_path[MAXPGPATH];
374372

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

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

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

@@ -419,6 +432,7 @@ copy_clog_xlog_xid(void)
419432
{
420433
copy_subdir_files("pg_multixact/offsets");
421434
copy_subdir_files("pg_multixact/members");
435+
422436
prep_status("Setting next multixact ID and offset for new cluster");
423437

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

441462
/*

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