upgrade: stop old server in case of permissions problem

Version: 9.2.4-11
Resolves: #896161
This commit is contained in:
Pavel Raiskup 2013-08-15 07:41:09 +02:00
parent 4dafc07c13
commit f9f152f08e
2 changed files with 67 additions and 1 deletions

View File

@ -0,0 +1,54 @@
diff --git a/contrib/pg_upgrade/server.c b/contrib/pg_upgrade/server.c
index c5ecb84..a519a9e 100644
--- a/contrib/pg_upgrade/server.c
+++ b/contrib/pg_upgrade/server.c
@@ -166,7 +166,6 @@ static void
stop_postmaster_atexit(void)
{
stop_postmaster(true);
-
}
@@ -235,7 +234,23 @@ start_postmaster(ClusterInfo *cluster)
false,
"%s", cmd);
- /* Check to see if we can connect to the server; if not, report it. */
+ /*
+ * We set this here to make sure atexit() shuts down the server,
+ * but only if we started the server successfully. We do it
+ * before checking for connectivity in case the server started but
+ * there is a connectivity failure. If pg_ctl did not return success,
+ * we will exit below.
+ */
+ if (pg_ctl_return)
+ os_info.running_cluster = cluster;
+
+ /*
+ * pg_ctl -w might have failed because the server couldn't be started,
+ * or there might have been a connection problem in _checking_ if the
+ * server has started. Therefore, even if pg_ctl failed, we continue
+ * and test for connectivity in case we get a connection reason for the
+ * failure.
+ */
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
PQstatus(conn) != CONNECTION_OK)
{
@@ -249,12 +264,13 @@ start_postmaster(ClusterInfo *cluster)
}
PQfinish(conn);
- /* If the connection didn't fail, fail now */
+ /*
+ * If pg_ctl failed, and the connection didn't fail, fail now. This
+ * could happen if the server was already running.
+ */
if (!pg_ctl_return)
pg_log(PG_FATAL, "pg_ctl failed to start the %s server, or connection failed\n",
CLUSTER_NAME(cluster));
-
- os_info.running_cluster = cluster;
}

View File

@ -60,7 +60,7 @@ Summary: PostgreSQL client programs
Name: postgresql
%global majorversion 9.2
Version: 9.2.4
Release: 10%{?dist}
Release: 11%{?dist}
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
# recognizes it as an independent license, so we do as well.
@ -118,6 +118,14 @@ Patch9: postgresql-9.2.4-perl-5.18.patch
Patch10: postgresql-9.2.4-aarch64-atomic.patch
Patch11: postgresql-9.2.4-aarch64-atomic-upgrade.patch
# When user complicates access of 'postgres' user to the database, the
# pg_upgrade can left the old server running - and re-run of pg_upgrade thus
# does not help. This patch stops the server in described scenario properly.
# ~> not yet upstream, patch by Bruce Momjian:
# ~> http://www.postgresql.org/message-id/20130812193347.GD12510@momjian.us
# ~> #896161
Patch12: postgresql-9.2.4-upgrade-and-perm-problems.patch
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
BuildRequires: perl(ExtUtils::Embed), perl-devel
BuildRequires: readline-devel zlib-devel
@ -347,6 +355,7 @@ benchmarks.
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch12 -p1
# We used to run autoconf here, but there's no longer any real need to,
# since Postgres ships with a reasonably modern configure script.
@ -1128,6 +1137,9 @@ fi
%endif
%changelog
* Thu Aug 15 2013 Pavel Raiskup <praiskup@redhat.com> - 9.2.4-11
- upgrade: stop old server in case of permissions problem (#896161)
* Mon Aug 12 2013 Pavel Raiskup <praiskup@redhat.com> - 9.2.4-10
- disable aggressive loop optimizations for old codebase (#993532)