mirror of
https://github.com/postgres/postgres.git
synced 2025-05-12 16:21:30 +03:00
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
This commit is contained in:
parent
2a7512bc7f
commit
cc58418096
@ -364,8 +364,24 @@ create_new_objects(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Delete the given subdirectory contents from the new cluster, and copy the
|
* Delete the given subdirectory contents from the new cluster
|
||||||
* files from the old cluster into it.
|
*/
|
||||||
|
static void
|
||||||
|
remove_new_subdir(char *subdir, bool rmtopdir)
|
||||||
|
{
|
||||||
|
char new_path[MAXPGPATH];
|
||||||
|
|
||||||
|
prep_status("Deleting files from new %s", subdir);
|
||||||
|
|
||||||
|
snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
|
||||||
|
if (!rmtree(new_path, rmtopdir))
|
||||||
|
pg_log(PG_FATAL, "could not delete directory \"%s\"\n", new_path);
|
||||||
|
|
||||||
|
check_ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy the files from the old cluster into it
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
copy_subdir_files(char *subdir)
|
copy_subdir_files(char *subdir)
|
||||||
@ -373,13 +389,10 @@ copy_subdir_files(char *subdir)
|
|||||||
char old_path[MAXPGPATH];
|
char old_path[MAXPGPATH];
|
||||||
char new_path[MAXPGPATH];
|
char new_path[MAXPGPATH];
|
||||||
|
|
||||||
prep_status("Deleting files from new %s", subdir);
|
remove_new_subdir(subdir, true);
|
||||||
|
|
||||||
snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, subdir);
|
snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, subdir);
|
||||||
snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
|
snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, subdir);
|
||||||
if (!rmtree(new_path, true))
|
|
||||||
pg_log(PG_FATAL, "could not delete directory \"%s\"\n", new_path);
|
|
||||||
check_ok();
|
|
||||||
|
|
||||||
prep_status("Copying old %s to new server", subdir);
|
prep_status("Copying old %s to new server", subdir);
|
||||||
|
|
||||||
@ -420,6 +433,7 @@ copy_clog_xlog_xid(void)
|
|||||||
{
|
{
|
||||||
copy_subdir_files("pg_multixact/offsets");
|
copy_subdir_files("pg_multixact/offsets");
|
||||||
copy_subdir_files("pg_multixact/members");
|
copy_subdir_files("pg_multixact/members");
|
||||||
|
|
||||||
prep_status("Setting next multixact ID and offset for new cluster");
|
prep_status("Setting next multixact ID and offset for new cluster");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -437,6 +451,13 @@ copy_clog_xlog_xid(void)
|
|||||||
}
|
}
|
||||||
else if (new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
|
else if (new_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Remove files created by initdb that no longer match the
|
||||||
|
* new multi-xid value.
|
||||||
|
*/
|
||||||
|
remove_new_subdir("pg_multixact/offsets", false);
|
||||||
|
remove_new_subdir("pg_multixact/members", false);
|
||||||
|
|
||||||
prep_status("Setting oldest multixact ID on new cluster");
|
prep_status("Setting oldest multixact ID on new cluster");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user