Bug 808256

Summary: postgresql-setup upgrade fails with 'invalid old port number'
Product: [Fedora] Fedora Reporter: Ian Donaldson <iand>
Component: postgresqlAssignee: Tom Lane <tgl>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 16CC: devrim, hhorak, tgl
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-30 14:00:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Ian Donaldson 2012-03-29 23:34:12 UTC
Description of problem:

Upgrading from FC15 to FC16, postgres wouldn't start and mentioned
we had to run: postgresql-setup upgrade

However this failed and the log contained this:


invalid old port number
Failure, exiting


Version-Release number of selected component (if applicable):

postgresql-server-9.1.3-1.fc16.x86_64
postgresql-upgrade-9.1.3-1.fc16.x86_64



How reproducible:

100%

Steps to Reproduce:
1. postgresql-setup upgrade
2.
3.
  
Actual results:

# postgresql-setup upgrade
Redirecting to /bin/systemctl  stop postgresql.service
Upgrading database: failed

See /var/lib/pgsql/pgupgrade.log for details.

# cat /var/lib/pgsql/pgupgrade.log
invalid old port number
Failure, exiting


Expected results:

success


Additional info:

Inspection of /usr/bin/postgresql-setup shows it extracting the port
from /lib/systemd/system/postgresql.service, but its extraction code
isn't coping with the commented mention of the port in there as well.

A quick fix is to modify this in /usr/bin/postgresql-setup:


--- postgresql-setup.orig       2012-02-27 16:46:03.000000000 +0000
+++ postgresql-setup    2012-03-29 23:13:27.777872259 +0000
@@ -35,8 +35,8 @@
 fi
 
 # Get port number and data directory from the service file
-PGPORT=`sed -n 's/Environment=PGPORT=//p' "${SERVICE_FILE}"`
-PGDATA=`sed -n 's/Environment=PGDATA=//p' "${SERVICE_FILE}"`
+PGPORT=`sed -n 's/^Environment=PGPORT=//p' "${SERVICE_FILE}"`
+PGDATA=`sed -n 's/^Environment=PGDATA=//p' "${SERVICE_FILE}"`

Comment 1 Tom Lane 2012-03-30 14:00:22 UTC
This is dealt with already in 9.1.3-2 and later.

*** This bug has been marked as a duplicate of bug 802835 ***