Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3c0471b

Browse files
committed
pg_upgrade: generate check error for left-over new tablespace
Previously, if pg_upgrade failed, and the user recreated the cluster butdid not remove the new cluster tablespace directory, a later pg_upgradewould fail since the new tablespace directory would already exists.This adds error reporting for this during check.Reported-by: Justin PryzbyDiscussion:https://postgr.es/m/20200925005531.GJ23631@telsasoft.comBackpatch-through: 9.5
1 parent7255943 commit3c0471b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎src/bin/pg_upgrade/check.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ static void check_for_tables_with_oids(ClusterInfo *cluster);
2727
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
2828
staticvoidcheck_for_jsonb_9_4_usage(ClusterInfo*cluster);
2929
staticvoidcheck_for_pg_role_prefix(ClusterInfo*cluster);
30+
staticvoidcheck_for_new_tablespace_dir(ClusterInfo*new_cluster);
3031
staticchar*get_canonical_locale_name(intcategory,constchar*locale);
3132

3233

@@ -187,6 +188,8 @@ check_new_cluster(void)
187188
check_is_install_user(&new_cluster);
188189

189190
check_for_prepared_transactions(&new_cluster);
191+
192+
check_for_new_tablespace_dir(&new_cluster);
190193
}
191194

192195

@@ -527,6 +530,43 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
527530
}
528531

529532

533+
/*
534+
* A previous run of pg_upgrade might have failed and the new cluster
535+
* directory recreated, but they might have forgotten to remove
536+
* the new cluster's tablespace directories. Therefore, check that
537+
* new cluster tablespace directories do not already exist. If
538+
* they do, it would cause an error while restoring global objects.
539+
* This allows the failure to be detected at check time, rather than
540+
* during schema restore.
541+
*
542+
* Note, v8.4 has no tablespace_suffix, which is fine so long as the
543+
* version being upgraded *to* has a suffix, since it's not allowed
544+
* to pg_upgrade from a version to the same version if tablespaces are
545+
* in use.
546+
*/
547+
staticvoid
548+
check_for_new_tablespace_dir(ClusterInfo*new_cluster)
549+
{
550+
charnew_tablespace_dir[MAXPGPATH];
551+
552+
prep_status("Checking for new cluster tablespace directories");
553+
554+
for (inttblnum=0;tblnum<os_info.num_old_tablespaces;tblnum++)
555+
{
556+
structstatstatbuf;
557+
558+
snprintf(new_tablespace_dir,MAXPGPATH,"%s%s",
559+
os_info.old_tablespaces[tblnum],
560+
new_cluster->tablespace_suffix);
561+
562+
if (stat(new_tablespace_dir,&statbuf)==0||errno!=ENOENT)
563+
pg_fatal("new cluster tablespace directory already exists: \"%s\"\n",
564+
new_tablespace_dir);
565+
}
566+
567+
check_ok();
568+
}
569+
530570
/*
531571
* create_script_for_old_cluster_deletion()
532572
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp