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

Commit26ebb0e

Browse files
List offending databases in pg_upgrade datallowconn check
The check for datallowconn being properly set on all databases in theold cluster errored out on the first instance, rather than report theset of problematic databases. This adds reporting to a textfile likehow many other checks are performed. While there, also add a commentto the function as per how other checks are commented.This check won't catch if template1 isn't allowing connections, sincethat's used for connecting in the first place. That error remains asit is today:connection to server on socket ".." failed: FATAL: database "template1" is not currently accepting connectionsAuthor: Jeevan Ladhe <jeevan.ladhe@enterprisedb.com>Reviewed-by: Suraj Kharage <suraj.kharage@enterprisedb.com>Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>Discussion:https://postgr.es/m/CAOgcT0McABqF_iFFQuuRf9is+gmYMsmUu_SWNikyr=2VGyP9Jw@mail.gmail.com
1 parentce95c54 commit26ebb0e

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

‎src/bin/pg_upgrade/check.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,13 @@ check_is_install_user(ClusterInfo *cluster)
682682
}
683683

684684

685+
/*
686+
*check_proper_datallowconn
687+
*
688+
*Ensure that all non-template0 databases allow connections since they
689+
*otherwise won't be restored; and that template0 explicitly doesn't allow
690+
*connections since it would make pg_dumpall --globals restore fail.
691+
*/
685692
staticvoid
686693
check_proper_datallowconn(ClusterInfo*cluster)
687694
{
@@ -691,9 +698,16 @@ check_proper_datallowconn(ClusterInfo *cluster)
691698
intntups;
692699
inti_datname;
693700
inti_datallowconn;
701+
FILE*script=NULL;
702+
charoutput_path[MAXPGPATH];
703+
boolfound= false;
694704

695705
prep_status("Checking database connection settings");
696706

707+
snprintf(output_path,sizeof(output_path),"%s/%s",
708+
log_opts.basedir,
709+
"databases_with_datallowconn_false.txt");
710+
697711
conn_template1=connectToServer(cluster,"template1");
698712

699713
/* get database names */
@@ -724,16 +738,37 @@ check_proper_datallowconn(ClusterInfo *cluster)
724738
* restore
725739
*/
726740
if (strcmp(datallowconn,"f")==0)
727-
pg_fatal("All non-template0 databases must allow connections, "
728-
"i.e. their pg_database.datallowconn must be true\n");
741+
{
742+
found= true;
743+
if (script==NULL&& (script=fopen_priv(output_path,"w"))==NULL)
744+
pg_fatal("could not open file \"%s\": %s\n",
745+
output_path,strerror(errno));
746+
747+
fprintf(script,"%s\n",datname);
748+
}
729749
}
730750
}
731751

732752
PQclear(dbres);
733753

734754
PQfinish(conn_template1);
735755

736-
check_ok();
756+
if (script)
757+
fclose(script);
758+
759+
if (found)
760+
{
761+
pg_log(PG_REPORT,"fatal\n");
762+
pg_fatal("All non-template0 databases must allow connections, i.e. their\n"
763+
"pg_database.datallowconn must be true. Your installation contains\n"
764+
"non-template0 databases with their pg_database.datallowconn set to\n"
765+
"false. Consider allowing connection for all non-template0 databases\n"
766+
"or drop the databases which do not allow connections. A list of\n"
767+
"databases with the problem is in the file:\n"
768+
" %s\n\n",output_path);
769+
}
770+
else
771+
check_ok();
737772
}
738773

739774

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp