[postgresql/f18] upgrade: stop old server in case of permissions problem

Pavel Raiskup praiskup at fedoraproject.org
Thu Aug 15 05:52:46 UTC 2013


commit ef3147bec7d1d9def9cc429e7807d849904a0a32
Author: Pavel Raiskup <praiskup at redhat.com>
Date:   Thu Aug 15 07:41:09 2013 +0200

    upgrade: stop old server in case of permissions problem
    
    (cherry-pick from fc20)
    
    Version: 9.2.4-2
    Resolves: #896161

 postgresql-9.2.4-upgrade-and-perm-problems.patch |   54 ++++++++++++++++++++++
 postgresql.spec                                  |   12 ++++-
 2 files changed, 65 insertions(+), 1 deletions(-)
---
diff --git a/postgresql-9.2.4-upgrade-and-perm-problems.patch b/postgresql-9.2.4-upgrade-and-perm-problems.patch
new file mode 100644
index 0000000..4cdcc77
--- /dev/null
+++ b/postgresql-9.2.4-upgrade-and-perm-problems.patch
@@ -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;
+ }
+ 
+ 
diff --git a/postgresql.spec b/postgresql.spec
index 7ff1605..ed0ce22 100644
--- a/postgresql.spec
+++ b/postgresql.spec
@@ -106,6 +106,14 @@ Patch6: postgresql-var-run-socket.patch
 # Comments for these patches are in the patch files.
 Patch7: postgresql-man.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
+Patch8: 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
@@ -333,6 +341,7 @@ benchmarks.
 %patch5 -p1
 %patch6 -p1
 %patch7 -p1
+%patch8 -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.
@@ -1101,11 +1110,12 @@ fi
 %endif
 
 %changelog
-* Mon Aug 12 2013 Pavel Raiskup <praiskup at redhat.com> - 9.2.4-2
+* Thu Aug 15 2013 Pavel Raiskup <praiskup at redhat.com> - 9.2.4-2
 - postgresql-setup: don't create whole path to server's data to make sure that
   the parent directory has correct permissions (#972425) (pick from fc20)
 - backport fix for manual pages (#948933) (pick from fc20)
 - fix README.rpm-dist for the bug (#969050) (pick from fc20)
+- upgrade: stop old server if perm. problem occur (#896161) (pick from fc20)
 
 * Thu Apr  4 2013 Tom Lane <tgl at redhat.com> 9.2.4-1
 - Update to PostgreSQL 9.2.4, for various fixes described at


More information about the scm-commits mailing list