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

Bug 1638498

Summary: Installer can't initialize DB, mistmatched UTF8/SQL_ASCII charset s
Product: [Community] Spacewalk Reporter: Corey <corey>
Component: InstallationAssignee: Michael Mráka <mmraka>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 2.8CC: mmraka
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: spacewalk-setup-postgresql-2.10.1-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-19 12:16:24 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:
Bug Depends On:    
Bug Blocks: 1802137    

Description Corey 2018-10-11 18:19:03 UTC
Description of problem: Installation of spacewalk fails when creating the default postgresql db


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


How reproducible:
Should be easy to reproduce


Steps to Reproduce:
1. Fresh install of CentOS 7, EPEL repo enabled, yum upgraded all packages, FDQN hostname set
2. rpm -Uvh https://copr-be.cloud.fedoraproject.org/results/@spacewalkproject/spacewalk-2.8/epel-7-x86_64/00736372-spacewalk-repo/spacewalk-repo-2.8-11.el7.centos.noarch.rpm
3. (cd /etc/yum.repos.d && curl -O https://copr.fedorainfracloud.org/coprs/g/spacewalkproject/java-packages/repo/epel-7/group_spacewalkproject-java-packages-epel-7.repo)
4. yum -y install spacewalk-setup-postgresql
5. yum -y install spacewalk-postgresql 
6. firewall-cmd --add-service=http ; firewall-cmd --add-service=https ; 
 firewall-cmd --add-port 5222/tcp ; firewall-cmd --runtime-to-perm
7. spacewalk-setup


Actual results:
[root@updates ~]# spacewalk-setup
** Database: Setting up database connection for PostgreSQL backend.
** Database: Installing the database:
** Database: This is a long process that is logged in:
** Database:   /var/log/rhn/install_db.log
*** Progress: ###
Could not install database.

[root@updates ~]# tail  /var/log/rhn/install_db.log
createdb: database creation failed: ERROR:  new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT:  Use the same encoding as in the template database, or use template0 as template.



Expected results:
Successful installation/DB setup



Additional info:
I was able to work around this issue (thanks to contributions in https://bugzilla.redhat.com/show_bug.cgi?id=1524221) by adding the following to my /etc/environment file.
[root@updates private]# cat /etc/environment
LANGUAGE="en_US:en"
LC_ALL="en_US.utf8"
LC_CTYPE="en_US.utf8"
LANG="en_US.utf8"

I then rebooted the server for the environment changes to take effect and confirmed the settings with:
[root@updates private]# env|grep LANG
LANG=en_US.utf8
LANGUAGE=en_US:en

I then deleted the failed pgsql data by running
[root@updates ~]# rm -rf /var/lib/pgsql/data

I then initialized the pgsql db
[root@updates ~]# postgresql-setup initdb
Initializing database ... OK

I then successfully ran spacewalk-setup and completed the installation
[root@updates ~]# spacewalk-setup
** Database: Setting up database connection for PostgreSQL backend.
psql: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory
Database "rhnschema" does not exist
** Database: Installing the database:
** Database: This is a long process that is logged in:
** Database:   /var/log/rhn/install_db.log
*** Progress: #
** Database: Installation complete.
** Database: Populating database.
*** Progress: ##########################
(redacted)

Comment 1 Michael Mráka 2019-07-04 11:41:20 UTC
Fixed in spacewalk git by
commit ec43dbc87385f16a605b8b9a9d803b19de854608
    1638498 - force UTF8 charset for database

Comment 2 Michael Mráka 2020-03-19 12:16:24 UTC
Spacewalk 2.10 has been released.
https://github.com/spacewalkproject/spacewalk/wiki/ReleaseNotes210