Bug 1319930

Summary: Schema upgrade 2.3-2.4 does not create rhnResetPassword table in PostgreSQL
Product: [Community] Spacewalk Reporter: mattpnz
Component: InstallationAssignee: Michael Mráka <mmraka>
Status: CLOSED WORKSFORME QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: low Docs Contact:
Priority: unspecified    
Version: 2.4CC: mattpnz, mmraka
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: spacewalk-schema-2.9.11-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-07-04 14:00:39 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:
Attachments:
Description Flags
Platform-independent version of schema upgrade script 013-rhnResetPassword.sql none

Description mattpnz 2016-03-21 20:52:00 UTC
Created attachment 1138805 [details]
Platform-independent version of schema upgrade script 013-rhnResetPassword.sql

Description of problem: 
After an upgrade to Spacewalk 2.4, unable to add new users


Version-Release number of selected component (if applicable): Spacewalk 2.4 (and 2.5) after upgrade from 2.3


How reproducible: Always


Steps to Reproduce:
1. Install Spacewalk 2.3
2. Upgrade to Spacewalk 2.4
3. Create new user

Actual results:
- User is not created
- "Internal server error" message in web UI
- Trace message with key contents "Caused by: com.redhat.rhn.common.db.WrappedSQLException: ERROR: relation "rhnresetpassword" does not exist"

Expected results:
User is added

Additional info:
Culprit appears to be file 013-rhnResetPassword.sql in the spacewalk-schema-2.3-to-spacewalk-schema-2.4 script collection. File as distributed has some Oracle-specific syntax that is not parsed by PGSQL. Attached version of the file has been corrected for PGSQL and verified to fix the problem.

Comment 1 mattpnz 2016-03-21 21:00:05 UTC
Forgot to include in description and steps that this is with PostgreSQL backend database.

Comment 2 Jan Dobes 2016-03-22 10:19:19 UTC
Did you run spacewalk-schema-upgrade after upgrade to Spacewalk 2.4?

Comment 3 mattpnz 2016-03-22 21:23:42 UTC
(In reply to Jan Dobes from comment #2)
> Did you run spacewalk-schema-upgrade after upgrade to Spacewalk 2.4?

Yes, multiple times, with roll-back-and-retry each time that I got this error and even a roll-back to a 2.2 backup and then upgrade through the sequence to 2.4. Ran spacewalk-schema-upgrade each time and always got the same result.

Without upgrading the schema from 2.3 to 2.4 adding users works fine, but there's the warning at the login screen about needing to upgrade the schema.

If spacewalk-schema-upgrade is not run after doing the package upgrades nothing breaks. It only breaks when the invalid schema upgrade is applied and the rhnResetPassword table is not created.

Comment 4 Jan Dobes 2016-03-23 09:45:50 UTC
When you run spacewalk-schema-upgrade, there is a path to the sql script that will do the upgrade. Is code creating rhnResetPassword table (from 013-* upgrade) in this file? Is table in database after upgrade? (check with spacewalk-sql -i <<< "\d rhnResetPassword")

Comment 5 mattpnz 2016-03-24 03:17:26 UTC
As I have run my fixed version of the script and now have changes in place I am unwilling to roll back and upgrade again, but looking at the .sql files generated by spacewalk-schema-upgrade shows me no mention of rhnResetPassword:

[root@spacewalk schema-upgrade]# pwd
/var/log/spacewalk/schema-upgrade
[root@spacewalk schema-upgrade]# grep -i rhnresetpassword *
[root@spacewalk schema-upgrade]#

I did look through the full schema after the last upgrade that didn't work and the rhnResetPassword table was not present. When I ran my corrected version of 013-rhnResetPassword.sql there was no failure related to that table existing.

Comment 6 Michael Mráka 2019-07-04 14:00:39 UTC
I've tested that Spacewalk 2.2 schema can be upgraded to 2.9 schema:

# /usr/bin/spacewalk-schema-upgrade

Please make sure all Spacewalk services apart from database are stopped.
Schema upgrade: [spacewalk-schema-2.2.32-1.el6] -> [spacewalk-schema-2.9.11-1.el6]
Searching for upgrade path: [spacewalk-schema-2.2.32-1] -> [spacewalk-schema-2.9.11-1]
Searching for upgrade path: [spacewalk-schema-2.2.32] -> [spacewalk-schema-2.9.11]
Searching for upgrade path: [spacewalk-schema-2.2] -> [spacewalk-schema-2.9]
The path: [spacewalk-schema-2.2] -> [spacewalk-schema-2.3] -> [spacewalk-schema-2.4] -> [spacewalk-schema-2.5] -> [spacewalk-schema-2.6] -> [spacewalk-schema-2.7] -> [spacewalk-schema-2.8] -> [spacewalk-schema-2.9]
Planning to run spacewalk-sql with [/var/log/spacewalk/schema-upgrade/20190704-167850-script.sql]

Please make sure you have a valid backup of your database before continuing.

Hit Enter to continue or Ctrl+C to interrupt:
Executing spacewalk-sql, the log is in
[/var/log/spacewalk/schema-upgrade/20190704-167850-to-spacewalk-schema-2.9.log].
The database schema was upgraded to version [spacewalk-schema-2.9.11-1.el6].


Because we are not able to reproduce the issue I'm closing the bug.
If you disagree feel free to update the reproducer and reopen the bug.