Bug 1315974

Summary: 5.6@Oracle to 5.7@PostgreSQL: ERROR: column "old_password" of relation "web_contact" does not exist
Product: Red Hat Satellite 5 Reporter: Jan Hutař <jhutar>
Component: UpgradesAssignee: Tomáš Kašpárek <tkasparek>
Status: CLOSED CURRENTRELEASE QA Contact: Ales Dujicek <adujicek>
Severity: high Docs Contact:
Priority: unspecified    
Version: 570CC: adujicek, tlestach
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rhn-upgrade-5.8.0.3-1-sat Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-06-21 12:11:56 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: 1393921    

Description Jan Hutař 2016-03-09 07:45:26 UTC
Description of problem:
I was unable to upgrade 5.6@Oracle to 5.7@PostgreSQL because of DB migration failing with:

psql:<stdin>:7197688: ERROR:  column "old_password" of relation "web_contact" does not exist
SIGPIPE received.


Version-Release number of selected component (if applicable):
Upgrading from satellite-schema-5.6.0.29-1.el6sat (not yet released but hopefully that is not an issue here)
Upgrading to Satellite-5.7.0-RHEL6-re20150108.2-x86_64.iso (satellite-schema-5.7.0.11-1.el6sat.noarch)


How reproducible:
1 of 1 attempt


Steps to Reproduce:
1. Attempt to upgrade 5.6@Oracle to 5.7@PostgreSQL, workaround bug 1315964


Actual results:
Sorry for few typos when entering new DB info, but keeping them in case they are important:

# /mnt/tmp/install.pl --upgrade --external-postgresql --run-updater=yes
* 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.
* Upgrade flag passed.  Stopping necessary services.
* Purging conflicting packages.
* Checking for uninstalled prerequisites.
There are some packages from Red Hat Enterprise Linux that are not part
of the @base group that Satellite will require to be installed on this
system. The installer will try resolve the dependencies automatically.
* Installing RHN packages.
Warning: yum did not install the following packages:
        OpenIPMI
        OpenIPMI-libs
        lm_sensors-libs
        net-snmp-libs
        uuid
* Now running spacewalk-setup.
* Setting up SELinux..
    (*)
** Database: Setting up database connection for PostgreSQL backend.
Hostname (leave empty for local)? Database? extpg.example.com
Username? mydbuser
Password? 
Could not connect to the database.  Your connection information may be incorrect.  Error: DBI connect('dbname=extpg.example.com','mydbuser',...) failed: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"? at /usr/share/perl5/vendor_perl/Spacewalk/Setup.pm line 1769

Hostname (leave empty for local)? extpg.example.com
Port [5432]? 
Database? mydbuser
Username? mydbpassword
Password? 
'' is not a valid response
Password? 
Could not connect to the database.  Your connection information may be incorrect.  Error: DBI connect('dbname=mydbuser;host=extpg.example.com;port=5432','mydbpassword',...) failed: FATAL:  no pg_hba.conf entry for host "192.168.122.155", user "mydbpassword", database "mydbuser", SSL off at /usr/share/perl5/vendor_perl/Spacewalk/Setup.pm line 1769

Hostname (leave empty for local)? extpg.example.com
Port [5432]? 
Database? mydb3
Username? mydbuser
Password? 
** Database: Populating database.
The Database has schema.  Would you like to clear the database [Y]? y
** Database: Clearing database.
** Database: Shutting down spacewalk services that may be using DB.
** Database: Services stopped.  Clearing DB.
** Database: Re-populating database.
*** Progress: ####################################
* Database: Starting Oracle to PostgreSQL database migration.
** Database: Trying to connect to Oracle database: succeded.
** Database: Migrating data.
*** Database: Migration process logged at: /var/log/rhn/rhn_db_migration.log
*** Data migration failed.  Exit value: 3.
Please examine /var/log/rhn/rhn_installation.log for more information.
# tail /var/log/rhn/rhn_db_migration.log
DELETE 2
DELETE 0
DELETE 0
DELETE 0
DELETE 0
DELETE 9
DELETE 0
DELETE 4
psql:<stdin>:7197688: ERROR:  column "old_password" of relation "web_contact" does not exist
SIGPIPE received.


Expected results:
Should work


Additional info:
It is completely possible issue is on my side. Please let me know.

Comment 1 Ales Dujicek 2016-09-21 08:47:53 UTC
Sat 5.6 schema contains web_contact with old_password column
But 5.7 schema, which is created during upgrade, contains web_contact without that column.

And ./install.pl --upgrade loads 5.6 dump directly to 5.7 schema
>install/lib/Spacewalk/Setup.pm:
>  system_or_exit(["/bin/bash", "-c",
>        "(set -o pipefail; /usr/bin/spacewalk-dump-schema" .
>        " --db=" . $oracle_creds->{'db-name'} .
>        " --user=" . $oracle_creds->{'db-user'} .
>        " --password=" . $oracle_creds->{'db-password'} .
>  " --from=" . $db_details->{'migrate_from'} .
>  " --to=" . $db_details->{'migrate_to'} .
>  " | spacewalk-sql" .
>        " --verbose" .
>        " --select-mode-direct" .
>        " - ) > " . DB_MIGRATION_LOG_FILE . ' 2>&1'],
>        1,
>        "*** Data migration failed.");
which cannot work.

Schema upgrade from 5.6 to 5.7 includes 
>satellite-schema-5.6-to-satellite-schema-5.7/004-web_contact-old_password.sql:
> alter table web_contact drop column old_password;

We would probably need to run spacewalk-schema-upgrade to get Oracle to 5.7 schema, first.

Comment 2 Tomáš Kašpárek 2016-11-07 14:44:35 UTC
Also happens during 5.6 -> 5.8 migrations.