Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1217317

Summary: rare fail when installing with managed db: psql: FATAL: the database system is starting up
Product: Red Hat Satellite 5 Reporter: Jan Hutař <jhutar>
Component: InstallerAssignee: Jan Dobes <jdobes>
Status: CLOSED DEFERRED QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 570CC: satqe-list, tkasparek, tlestach
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1182044 Environment:
Last Closed: 2018-04-09 14:38:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Hutař 2015-04-30 06:03:58 UTC
This is also issue when installing Satellite wihh embedded PostgreSQL.

+++ This bug was initially created as a clone of Bug #1182044 +++

Description of problem:
Rarely when you are doing `./install.pl --upgrade --managed-db` it might fail.


Version-Release number of selected component (if applicable):
Satellite-5.7.0-RHEL6-re20150108.2-x86_64


How reproducible:
rarely (seen once and done about 10 runs of the command)


Steps to Reproduce:
1. # /mnt/tmp/install.pl --upgrade --managed-db


Actual results:
# /mnt/tmp/install.pl --upgrade --managed-db
* Starting Red Hat Satellite installer.
* Performing pre-install checks.
* Pre-install checks complete.  Beginning installation.
* RHN Registration.
** Registration: System is already registered with RHN.  Not re-registering.
* Upgrading managed DB packages.
*** Upgrading embedded database.
There was a problem during embedded database upgrade.
  Exit value: 2.
Please examine /var/log/rhn/rhn_installation.log for more information.
# tail /var/log/rhn/rhn_installation.log
Running Transaction
  Installing : postgresql92-postgresql-upgrade-9.2.8-2.el6.x86_64           1/1 
  Verifying  : postgresql92-postgresql-upgrade-9.2.8-2.el6.x86_64           1/1 

Installed:
  postgresql92-postgresql-upgrade.x86_64 0:9.2.8-2.el6                          

Complete!
Starting postgresql service: [  OK  ]
psql: FATAL:  the database system is starting up


When I have re-ran /usr/bin/spacewalk-upgrade-postgresql manually, upgrade passed.


Expected results:
Should work


Additional info:
This is a code-path:

### /mnt/tmp/install.pl:
[...]
if ($opts{"upgrade"} and $opts{"managed-db"}) {
  install_satellite_repo(\%opts);
  print loc("* Upgrading managed DB packages.\n");
  install_embedded_postgresql(\%opts);
  Spacewalk::Setup::postgresql_upgrade_embedded_db();
  print loc("* Managed DB instance was successfully upgraded.\n");
  exit 0;
}
[...]

### /mnt/tmp/install/lib/Spacewalk/Setup.pm:
[...]
sub postgresql_upgrade_embedded_db {
    print loc("*** Upgrading embedded database.\n");
    system_or_exit(['/usr/bin/spacewalk-upgrade-postgresql', ''], 1, "There was a problem during embedded database upgrade.\n");
    return 0;
}
[...]

### /usr/bin/spacewalk-upgrade-postgresql:
[...]
service postgresql start
DB_TIMEZONE=$(echo "show timezone;" | psql -U $DB_USER -d $DB_NAME -h localhost | sed -n 3p | sed 's/ //g')
LOG_TIMEZONE=$(echo "show log_timezone;" | psql -U $DB_USER -d $DB_NAME -h localhost | sed -n 3p | sed 's/ //g')
service postgresql stop
[...]

So looks like we are trying to stop PostgreSQL 8.4 right after we have started and we are not checking result of the commands betweet that start and stop so its results can be empty or something.

--- Additional comment from Jan Hutař on 2015-02-04 00:48:23 EST ---

Reported bug 1188942, which might be relevant.

--- Additional comment from Jan Hutař on 2015-04-30 02:00:54 EDT ---

Pavel Raiskup mentioned PostgreSQL initscript configuration option which can achieve that. Problem is that it appears in rh-postgresql94 from RHSCL-2.0: bug 1188942 comment #3

Comment 2 Tomas Lestach 2018-04-09 14:38:19 UTC
We have re-reviewed this bug, as part of an ongoing effort to improve Satellite/Proxy feature and bug updates, review and backlog.

This is a low priority bug and has no currently open customer cases. While this bug may still valid, we do not see it being implemented prior to the EOL of the Satellite 5.x product. As such, this is being CLOSED DEFERRED. 

Closing now to help set customer expectations as early as possible. You are welcome to re-open this bug if needed.