Re: BUG #13612: postgresql94-setup initdb in kickstart fails - Mailing list pgsql-bugs

From Allan.Kristensen@schneider-electric.com
Subject Re: BUG #13612: postgresql94-setup initdb in kickstart fails
Date
Msg-id OF5C73D522.300CF89C-ONC1257EEB.002DC722-C1257EEB.0032360A@schneider-electric.com
Whole thread Raw
In response to Re: BUG #13612: postgresql94-setup initdb in kickstart fails  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
> On Fri, Sep 11, 2015 at 08:26:38AM +0200,
Allan.Kristensen@schneider-electric.com wrote:
> >  lvaro Herrera wrote:
> > > Bruce Momjian wrote:
> > > > On Thu, Sep 10, 2015 at 09:23:45AM -0400, Bruce Momjian wrote:
> > > > > On Thu, Sep 10, 2015 at 04:20:17PM +0300, Devrim Gunduz wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > On Thu, 2015-09-10 at 09:11 -0400, Bruce Momjian wrote:
> > > > > > > Uh, we didn't write or maintain that file.
> > > > > >
> > > > > > It comes with the RPMs.
> > > > > >
> > > > > > Allan, I'll take a look soon.
> > > > >
> > > > > Oh, OK.  I wasn't sure if it was something from the RPMs, or
something
> > > > > Red Hat wrote.
> > > >
> > > > FYI, I am getting an email failure from the original poster, so
there
> > > > might not be much point in replying to him:
> > > >
> > > >   User allan.kristsensen
(allan.kristsensen@schneider-electric.com) not
> > > >   listed in Domino Directory
> > >
> > > He mistyped his address in the bug report form.  I corrected it
here.
> >
> > Thanks  lvaro and sorry about the email address.
> >
> > The rpm in question postgresql94-server-9.4.4-1PGDG.rhel7.x86_64.rpm
downloaded
> > from the http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/ repo.
>
> Thanks.  I would be interested to know how email list subscribers like
> me can determine who the source of the OS-specific script is so we can
> properly route such messsages.
>
> --
>   Bruce Momjian  <bruce@momjian.us>        http://momjian.us
>   EnterpriseDB                             http://enterprisedb.com
>
>   + Everyone has their own god. +

I have been using the lines from OP for over a month now and did not find
any issues. What is the process for incorporating it into the next
release?

Here is the diff if that makes life easier.

########### Diff start ###########
--- /usr/pgsql-9.4/bin/postgresql94-setup       2015-06-11
13:19:27.000000000 +0200
+++ /usr/pgsql-9.4/bin/postgresql94-setup.new   2015-10-26
16:05:28.082858681 +0100
@@ -79,32 +79,34 @@
                 sed 's/^Environment=//' | tr ' ' '\n' |
                 sed -n 's/^PGDATA=//p' | tail -n 1`
 if [ x"$PGDATA" = x ]; then
-    echo "failed to find PGDATA setting in ${SERVICE_NAME}.service"
-    exit 1
+    # Find the unit file for new version.
+    if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]
+    then
+        SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
+    elif [ -f "/lib/systemd/system/${SERVICE_NAME}.service" ]
+    then
+        SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service"
+    else
+        echo "Could not find systemd unit file ${SERVICE_NAME}.service"
+        exit 1
+    fi
+
+    # Get data directory from the service file
+    PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"`
+
+    if [ x"$PGDATA" = x ]; then
+        echo "Failed to find PGDATA setting in ${SERVICE_NAME}.service"
+        exit 1
+    fi
 fi

-# Find the unit file for new version.
-if [ -f "/etc/systemd/system/${SERVICE_NAME}.service" ]
-then
-    SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
-elif [ -f "/lib/systemd/system/${SERVICE_NAME}.service" ]
-then
-    SERVICE_FILE="/lib/systemd/system/${SERVICE_NAME}.service"
-else
-    echo "Could not find systemd unit file ${SERVICE_NAME}.service"
-    exit 1
-fi
+export PGDATA

 # Log file for pg_upgrade
 PGUPLOG=/var/lib/pgsql/$PGMAJORVERSION/pgupgrade.log
 # Log file for initdb
 PGLOG=/var/lib/pgsql/9.4/initdb.log

-# Get data directory from the service file
-PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"`
-
-export PGDATA
-
 # For SELinux we need to use 'runuser' not 'su'
 if [ -x /sbin/runuser ]
 then
########### Diff end ###########


Best regards
Allan Kristensen
_____________________________________________________________________________________


Allan Kristensen  |   APC by Schneider Electric   |  IT Business  |
Denmark  |   Configuration Management Administrator
Phone: +45 72190143  |   Mobile: +45 20752220
Email: allan.kristensen@schneider-electric.com  |   Site:
www.schneider-electric.dk  |   Address: Silcon Alle, 6000 Kolding, Denmark


*** Please consider the environment before printing this e-mail ***

pgsql-bugs by date:

Previous
From: michael@snupps.com
Date:
Subject: BUG #13739: Recurring corrupted page pointer panics on hot-standby replica
Next
From: chenhj
Date:
Subject: Re: BUG #13723: "duplicate key" error occurs when update delete and insert the same row concurrently