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

Bug 662563

Summary: cannot drop index used for enforcement of unique/primary key during upgrades
Product: [Community] Spacewalk Reporter: Jan Pazdziora (Red Hat) <jpazdziora>
Component: InstallationAssignee: Jan Pazdziora (Red Hat) <jpazdziora>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: low    
Version: 1.2CC: mmraka
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-schema-1.3.9-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-02-08 08:42:21 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: 653453    

Description Jan Pazdziora (Red Hat) 2010-12-13 07:53:14 UTC
Description of problem:

wlovins reported on #spacewalk on freenode:

I'm doing a Spacewalk 1.0 -> 1.2 ugprade and I've run into a problem. The schema upgrade failed on migration 210-rhnPackage-indexes.sql (in the spacewalk-schema-1.1-to-spacewalk-schema-1.2 directory). All of the 1.0 -> 1.1 migrations ran fine, but this one fails with: drop index rhn_package_path_idx with an ORA-02429 error (cannot drop index used for enforcement of unique/primary key).

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

Upgrade 1.0 -> 1.2.

How reproducible:

wlovins has seen it.

Steps to Reproduce:
1. Run spacewalk-schema-upgrade.
  
Actual results:

SQL> select 'spacewalk-schema-1.1-to-spacewalk-schema-1.2/209-rhnErrataClonedTmp-indexes.sql' from dual;

'SPACEWALK-SCHEMA-1.1-TO-SPACEWALK-SCHEMA-1.2/209-RHNERRATACLONEDTMP-INDEXES.SQ
-------------------------------------------------------------------------------
spacewalk-schema-1.1-to-spacewalk-schema-1.2/209-rhnErrataClonedTmp-indexes.sql

SQL> 
SQL> drop index rhn_eclonedtmp_teid_feid_idx;

Index dropped.

SQL> 
SQL> commit;

Commit complete.

SQL> set echo on
SQL> spool /var/log/spacewalk/schema-upgrade/20101212-133124-to-spacewalk-schema-1.2.log append
SQL> whenever sqlerror exit sql.sqlcode
SQL> select 'spacewalk-schema-1.1-to-spacewalk-schema-1.2/210-rhnPackage-indexes.sql' from dual;

'SPACEWALK-SCHEMA-1.1-TO-SPACEWALK-SCHEMA-1.2/210-RHNPACKAGE-INDEXES.SQ
-----------------------------------------------------------------------
spacewalk-schema-1.1-to-spacewalk-schema-1.2/210-rhnPackage-indexes.sql

SQL> 
SQL> drop index rhn_package_id_nid_paid_idx;

Index dropped.

SQL> drop index rhn_package_path_idx;
drop index rhn_package_path_idx
           *
ERROR at line 1:
ORA-02429: cannot drop index used for enforcement of unique/primary key


Disconnected from Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
Upgrade failed, please see log in [/var/log/spacewalk/schema-upgrade/].

Expected results:

No errors.

Additional info:

Comment 1 Jan Pazdziora (Red Hat) 2011-01-05 16:20:33 UTC
John reports to have hit this issue during upgrade from 0.7 to 1.2:

https://www.redhat.com/archives/spacewalk-list/2011-January/msg00028.html

Comment 2 Michael Mráka 2011-01-10 08:19:48 UTC
I'm not sure why in some cases primary / unique constraint takes a different index than usually.

Fixed in spacewalk git by
commit 339c842924037eff31b50ec8ea490e4ed59ea3fe
    662563 - in 0.7 rhn_sndpb_pid_ptype_idx was used for rhn_sndpb_probe_id_pk enforcement
    
    we need to disable and re-enable primary key so it will
    create it's own index instead of dropped one
commit 676f5dbf2cae684a0a2a819a3c563cb8c1282603
    662563 - in 0.7 rhn_efilectmp_cid_efid_idx was used for rhn_efilectmp_efid_cid_uq enforcement
    
    we need to disable and re-enable unique key so it will
    use a different index instead of dropped one
commit db6631a53c328238d2189cabbf2221fbc70dfe79
    662563 - in 0.7 web_contact_id_oid_cust_luc was used for web_contact_pk enforcement
    
    we need to disable and re-enable primary key so it will
    create it's own index instead of dropped one
commit 76ea1d5ae412252d446b53c03ebab4601793168d
    662563 - in 0.7 rhn_package_path_idx was used for rhn_package_id_pk enforcement
    
    we need to disable and re-enable rhn_package_id_pk so it will create it's
    own index instead of dropped one

Comment 3 Tomas Lestach 2011-02-03 12:21:44 UTC
Moving ON_QA ...

Comment 4 Tomas Lestach 2011-02-08 08:42:21 UTC
This bug has been fixed in Spacewalk 1.3.