Bug 1579268

Summary: Upgrade of PostgreSQL during RHV 4.1 to 4.2 upgrade fails with locale mismatch
Product: Red Hat Enterprise Virtualization Manager Reporter: Peter McGowan <pmcgowan>
Component: ovirt-engineAssignee: Yedidyah Bar David <didi>
Status: CLOSED CURRENTRELEASE QA Contact: Lucie Leistnerova <lleistne>
Severity: high Docs Contact:
Priority: urgent    
Version: 4.2.3CC: amashah, aperotti, bgraveno, didi, dmardones, gchakkar, lsurette, mavital, mburgerh, mkalinin, mperina, pmcgowan, pstehlik, rabraham, rbalakri, Rhev-m-bugs, sbonazzo, shipatil, sraje, srevivo, stirabos, usurse, ykaul, ylavi
Target Milestone: ovirt-4.2.3-1Keywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.2.3.6 Doc Type: If docs needed, set a value
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-06-21 12:02:48 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:
Attachments:
Description Flags
Engine setup log none

Description Peter McGowan 2018-05-17 09:31:02 UTC
Description of problem:
Attempting to upgrade a RHV 4.1 installation to 4.2 fails with an error during the PostgreSQL upgrade. The file /var/lib/pgsql/upgrade_rh-postgresql95-postgresql.log contains the error: 

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

The databases on the server do indeed have mixed locales:

postgres=# \l
                                             List of databases
         Name         |        Owner         | Encoding |   Collate   |    Ctype    |   Access privileges
----------------------+----------------------+----------+-------------+-------------+-----------------------
 engine               | engine               | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 ovirt_engine_history | ovirt_engine_history | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres             | postgres             | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 |
 template0            | postgres             | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
                      |                      |          |             |             | postgres=CTc/postgres
 template1            | postgres             | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
                      |                      |          |             |             | postgres=CTc/postgres
(5 rows)

The system locale is as follows:

# locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

Version-Release number of selected component (if applicable):
Upgrade from 4.1 to 4.2

How reproducible:
Every time

Steps to Reproduce:
1. Unsure. The existing RHV system was upgraded from 4.0 to 4.1, but I'm not sure how the original locale settings were created.

Actual results:
Upgrade failure

Expected results:
Upgrade success

Additional info:

Comment 1 Yaniv Lavi 2018-05-17 09:44:08 UTC
I believe many of our customers will be affected, by the unfiltered DB check.
Can you please assign urgently? I believe this is an async candidate.

Comment 2 Yedidyah Bar David 2018-05-17 09:52:16 UTC
(In reply to Peter McGowan from comment #0)
> Steps to Reproduce:
> 1. Unsure. The existing RHV system was upgraded from 4.0 to 4.1, but I'm not
> sure how the original locale settings were created.

This is the hard part :-(

I'd expected this bug to be fixed by the fix to bug 1528371 (that is, close it as duplicate of it), but apparently it's not, but not sure how to reproduce.

Please attach engine-setup logs, for a start, so that we can see we passed the correct/intended options to postgresql-setup. If we did, we need to understand how to reproduce.

Comment 3 Sandro Bonazzola 2018-05-17 10:09:54 UTC
Restoring lost needinfo

Comment 5 Peter McGowan 2018-05-17 10:13:41 UTC
Created attachment 1437871 [details]
Engine setup log

Comment 6 Peter McGowan 2018-05-17 10:22:06 UTC
As far as I can remember, the RHV 4.0 system was a clean RHEL 7 installed on 2017-12-05, expressly to upgrade a RHEV 3.6 environment. I would have installed a fairly basic RHEL 7 installation as suggested by the upgrade docs, then performed the steps to export the old 3.6 databases and install RHV 4.0. I don't remember explicitly setting the locale but I installed the RHEL 7 system using the GUI installer, so it was probably set by anaconda when I set my timezone.

Comment 7 Yedidyah Bar David 2018-05-17 10:22:55 UTC
Thanks. The fix for 1528371 didn't work - e.g., we didn't check lc_collate. Looking

Comment 8 Yedidyah Bar David 2018-05-17 10:32:44 UTC
OK, now I understand.

Seems like the fix for bug 1528371 for the 4.2 branch was broken.

Sorry, must have been something in the way I handled the back-porting.

Will fix soon.

Comment 10 Lucie Leistnerova 2018-05-28 11:45:59 UTC
Engine upgraded with postgres database in SQL_ASCII or en_GB.UTF-8 encoding with success.

verified in ovirt-engine-4.2.3.8-0.1.el7.noarch

Comment 14 Franta Kust 2019-05-16 13:08:49 UTC
BZ<2>Jira Resync