Bug 506272

Summary: Schema upgrade fails for satellites synced against webqa
Product: Red Hat Satellite 5 Reporter: Milan Zázrivec <mzazrivec>
Component: UpgradesAssignee: Milan Zázrivec <mzazrivec>
Status: CLOSED CURRENTRELEASE QA Contact: Steve Salevan <ssalevan>
Severity: medium Docs Contact:
Priority: low    
Version: 530CC: cperry, jmatthew, mmraka
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: sat530 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-08-27 17:38:26 UTC Type: ---
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: 456986    

Description Milan Zázrivec 2009-06-16 14:07:13 UTC
Description of problem:
webqa.rhn.redhat.com currently contains data required for proper
sun4v architecture support (tables: rhnServerArch, rhnPackageArch,
rhnChannelPackageArchCompat, rhnServerPackageArchCompat).

When syncing a content from webqa, all sun4v - related rows from
these tables will be synced to the satellite in question (regardless
of the satellite version).

Current schema upgrade scripts for Satellite 5.3.0 are not able to
deal with this setup, as they naively assume these rows do not exist
yet, try to insert the data, which in this particular situation results
into "ORA-00001: unique constraint (...) violated" errors -> schema
upgrade fails.

These sun4v related rows are not present in rhn.redhat.com (production),
but most likely will be once Satellite 5.3.0 is released.

Schema upgrade scripts for 5.3.0 need to be modified so that they're
able to deal with this setup.

Version-Release number of selected component (if applicable):
satellite-schema-5.3.0.21-1
spacewalk-schema-0.5.20-16

How reproducible:
Always

Steps to Reproduce:
1. Install Satellite 5.2.0 or older
2. Activate the satellite against webqa
3. satellite-sync -c ...
4. Upgrade the satellite to 5.3.0
  
Actual results:
Schema upgrade fails:

SQL> insert into rhnServerPackageArchCompat
  2  (server_arch_id, package_arch_id, preference) values
  3  (LOOKUP_SERVER_ARCH('sparc-sun4v-solaris'), LOOKUP_PACKAGE_ARCH('sparc.sun4v-solaris'), 10);
insert into rhnServerPackageArchCompat
*
ERROR at line 1:
ORA-00001: unique constraint (RHNSAT.RHN_SP_AC_PREF_SAID_UQ) violated

Expected results:
Schema upgrade finished successfully.

Additional info:
N/A

Comment 1 Brandon Perkins 2009-06-16 15:41:16 UTC
Please see  Bug 486401 -  Satellite sync while syncing arch information with hosted, deletes some 'sun4v' related rows in database for information on the hosted-side of this bug.

Comment 3 Milan Zázrivec 2009-06-17 11:16:02 UTC
spacewalk.git master:
20b52a6a94f44b24ca987dec98d19d8cb99445a9
250e5a1536e0e62df0732145d216b56cbc7d21e9
afb63ccc8264145acd3e43367fe8cbd56c0a4908
e80744f3c0d0e69ef1555becc5ce22c5f0b8e71e
1065dca956a9b5e024557e876f76bf7962ef3f2b
c3fe772fb1a214b0d414d8e5f999c06fdf640a9d
100c9fae0909e670084dc8f119e8fa0538525923

spacewalk.git VADER:
a54ab1609cdfbcbca12cdb0b7b6d5da79991e09c
4af98db7f511887ee028156aea674f3abc7a9017
44bb771227bc8efcf871a24641137655a527bffa
a2703fff77f228a84e9650b848c0ea4ce904de67
b46ba1d4a411670dcd7ba1b73bc99bd3ce1267f2
823cb97555a2d0459ba6a8ec0bd033fc4caa3a66
86d39c282d02515b6f5874e09b8518f6da58a9b9

Comment 4 Milan Zázrivec 2009-06-20 09:00:06 UTC
spacewalk-schema-0.5.20-17

Comment 5 Steve Salevan 2009-07-16 19:28:53 UTC
VERIFIED on 7/14 build, against a 3.7.1 and a 5.2 Satellite.

Comment 6 Michael Mráka 2009-08-27 08:43:56 UTC
Verified in stage -> RELEASE_PENDING.

No unique constraint error.

# sqlplus rhnsat@rhnsat
SQL> select * from rhnServerPackageArchCompat spac
                        where spac.server_arch_id = LOOKUP_SERVER_ARCH('sparc-sun4m-solaris')
                          and spac.package_arch_id = LOOKUP_PACKAGE_ARCH('noarch-solaris-patch');
SERVER_ARCH_ID PACKAGE_ARCH_ID PREFERENCE CREATED   MODIFIED
-------------- --------------- ---------- --------- ---------
          1020             134        510 26-AUG-09 26-AUG-09

# /usr/bin/spacewalk-schema-upgrade
Schema upgrade: [rhn-satellite-schema-5.2.0-8] -> [satellite-schema-5.3.0.23-1.el5sat]
Searching for upgrade path: [rhn-satellite-schema-5.2.0-8] -> [satellite-schema-5.3.0.23-1]
Searching for upgrade path: [rhn-satellite-schema-5.2.0] -> [satellite-schema-5.3.0.23]
Searching for upgrade path: [rhn-satellite-schema-5.2] -> [satellite-schema-5.3.0]
Searching for upgrade path: [rhn-satellite-schema-5.2] -> [satellite-schema-5.3]
The path: [rhn-satellite-schema-5.2] -> [satellite-schema-5.3]
Planing to run sqlplus with [/var/log/spacewalk/schema-upgrade/20090827-103114-script.sql]
Hit Enter to continue or Ctrl+C to interrupt:
Executing sqlplus, the logs are in /var/log/spacewalk/schema-upgrade/20090827-103114-*.
The database schema was upgraded to version [satellite-schema-5.3.0.23-1.el5sat].

# sqlplus rhnsat@rhnsat
SQL> select * from rhnServerPackageArchCompat spac
                        where spac.server_arch_id = LOOKUP_SERVER_ARCH('sparc-sun4m-solaris')
                          and spac.package_arch_id = LOOKUP_PACKAGE_ARCH('noarch-solaris-patch');
SERVER_ARCH_ID PACKAGE_ARCH_ID PREFERENCE CREATED   MODIFIED
-------------- --------------- ---------- --------- ---------
          1020             134        610 26-AUG-09 27-AUG-09

Comment 7 Brandon Perkins 2009-08-27 17:38:26 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1235.html