Bug 1528371

Summary: engine-setup fails to upgrade postgres from 9.2 to 9.5 if the system wide locale differs from system wide locale at first installation time
Product: [oVirt] ovirt-engine Reporter: Simone Tiraboschi <stirabos>
Component: Setup.EngineCommonAssignee: Yedidyah Bar David <didi>
Status: CLOSED CURRENTRELEASE QA Contact: Lucie Leistnerova <lleistne>
Severity: medium Docs Contact:
Priority: high    
Version: 4.2.0CC: bgraveno, bugs, logank, lsvaty, ylavi
Target Milestone: ovirt-4.2.2Flags: rule-engine: ovirt-4.2+
ylavi: blocker+
Target Release: 4.2.2.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
This update enables engine-setup to upgrade PostgreSQL 9.2 to 9.5, even when the locale of the 9.2 database is different from the system locale.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-29 10:56:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Integration RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Simone Tiraboschi 2017-12-21 16:14:16 UTC
Description of problem:
engine-setup fails to upgrade postgres from 9.2 to 9.5 if the system wide locale differs from system wide locale at first installation time

engine-setup initializes its DB in en_US.UTF-8 while postgres own DB is initialized in system wide locale.
pg_upgrade cannot change DB locale on the fly on upgrades.

So if the user changed the system wide locale before running engine-setup to update the system from 4.1 to 4.2 and so from postgres 9.2 to postgres 9.5, engine-setup will fail with:

2017-12-20 15:53:42,967+0100 DEBUG otopi.plugins.ovirt_engine_setup.ovirt_engine.db.dbmsupgrade plugin.execute:926 execute-output: ('/opt/rh/rh-postgresql95/root/usr/bin/postgresql-setup', '--upgrade', '--upgrade-from=postgresql') stderr:
 * upgrading from 'postgresql.service' to 'rh-postgresql95-postgresql.service'
 * Upgrading database.
ERROR: pg_upgrade tool failed
ERROR: Upgrade failed.
 * See /var/lib/pgsql/upgrade_rh-postgresql95-postgresql.log for details.

2017-12-20 15:53:42,968+0100 DEBUG otopi.transaction transaction._prepare:66 exception during prepare phase
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/otopi/transaction.py", line 62, in _prepare
    element.prepare()
  File "/usr/share/ovirt-engine/setup/ovirt_engine_setup/engine_common/postgres.py", line 716, in prepare
    raiseOnError=True,
  File "/usr/lib/python2.7/site-packages/otopi/plugin.py", line 931, in execute
    command=args[0],
RuntimeError: Command '/opt/rh/rh-postgresql95/root/usr/bin/postgresql-setup' failed to execute

And in /var/lib/pgsql/upgrade_rh-postgresql95-postgresql.log something like:
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* system OID user data types                ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for invalid "line" user columns                    ok
Creating dump of global objects                             ok
Creating dump of database schemas
  engine
  ovirt_engine_history
  postgres
  template1
                                                            ok

lc_collate values for database "postgres" do not match:  old "en_US.UTF-8", new "de_DE.UTF-8"
Failure, exiting


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

How reproducible:
100%

Steps to Reproduce:
1. setup oVirt-engine 4.1 with a specific locale
2. change system wide locale
3. add 4.2 repo and try to upgrade with engine-setup

Actual results:
RuntimeError: Command '/opt/rh/rh-postgresql95/root/usr/bin/postgresql-setup' failed to execute

Expected results:
A successful upgrade or a clear error stating how to fix 

Additional info:

workaround:
check the expected system wide locale in /var/lib/pgsql/upgrade_rh-postgresql95-postgresql.log, temporary set it under /etc/locale.conf, execute engine-setup to upgrade to 4.2 and then you can safely revert back /etc/locale.conf to what you need

Comment 1 Lucie Leistnerova 2018-03-07 12:41:23 UTC
Upgrade of engine with changed locales was successful and migrated databases stayed en_US.UTF-8. The same for DWH upgrade on separate machine.

verified in ovirt-engine-setup-4.2.2.2-0.1.el7.noarch

Comment 2 Sandro Bonazzola 2018-03-29 10:56:09 UTC
This bugzilla is included in oVirt 4.2.2 release, published on March 28th 2018.

Since the problem described in this bug report should be
resolved in oVirt 4.2.2 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.