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

Commita106236

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 parentc8a2bb0 commita106236

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

@@ -180,6 +181,8 @@ check_new_cluster(void)
180181
check_is_install_user(&new_cluster);
181182

182183
check_for_prepared_transactions(&new_cluster);
184+
185+
check_for_new_tablespace_dir(&new_cluster);
183186
}
184187

185188

@@ -520,6 +523,43 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
520523
}
521524

522525

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp