Bug 1745516

Summary: Multiple duplicate index entries are present in candlepin database
Product: Red Hat Satellite Reporter: Ranjan Kumar <rankumar>
Component: CandlepinAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: bcourt, egolov, inecas, mbacovsk, nmoumoul, zhunting
Target Milestone: 6.8.0Keywords: Performance, Reopened, Triaged, Upgrades
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: candlepin-2.10.0-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1752975 (view as bug list) Environment:
Last Closed: 2020-10-27 12:59:02 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: 1752975    
Bug Blocks:    

Description Ranjan Kumar 2019-08-26 10:08:43 UTC
Description of problem: There are multiple duplicate indexes present in candlepin database. Having identical indexes means the DB is spending more time updating two indexes when only one needs to be updated. Duplicate indexes should be cleaned up and there should be a workaround to cleanup indexes in the current version. We should remove the unwanted indexes during the upgrades

In Customer DB, these are the duplicate indexes are present in the DB 

 size  |                 idx1                  |           idx2           
--------+---------------------------------------+--------------------------
 262 MB | cp_content_override_key_id_for_cs_idx | cp_content_override_idx1 
 576 kB | cp_pool_source_stack_pool_ukey        | idx_sourcestack_pool_fk  
 32 kB  | cp_dist_version_pkey                  | cp_dist_version_id_idx   

In local environment Satellite 6.5(upgraded from 6.4) having below duplicate indexes

#su - postgres -c "psql -d candlepin -c 'SELECT indrelid::regclass AS TableName,array_agg(indexrelid::regclass) AS Indexes FROM pg_index GROUP BY indrelid,indkey HAVING COUNT(*) > 1;;'"
      tablename       |                         indexes                          
----------------------+----------------------------------------------------------
 cp_dist_version      | {cp_dist_version_id_idx,cp_dist_version_pkey}
 cp_pool_source_stack | {cp_pool_source_stack_pool_ukey,idx_sourcestack_pool_fk}
(2 rows)



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


How reproducible: Always


Steps to Reproduce:
1. Try to find duplicate indexes using SQL query as per summary

Actual results: There are multiple duplicates indexes


Expected results: Duplicate indexes should not be present

Comment 3 Barnaby Court 2019-09-12 14:02:31 UTC
Index entries such as cp_content_override_key_id_for_cs_idx where hand created by the customer. Satellite is now providing providing equivalent indexes. As the customer created the original index by hand, if the customer does not wish to have duplicate indexes for the same fields, the customer should delete the indexes that they created.

Comment 7 Barnaby Court 2019-09-17 17:07:49 UTC
Moving to new as there were 2 other pairs of indexes that are worth considering cleanup:

cp_pool_source_stack_pool_ukey & idx_sourcestack_pool_fk 
cp_dist_version_pkey & cp_dist_version_id_idx

Comment 8 Nikos Moumoulidis 2020-04-30 12:19:25 UTC
The Candlepin bz has been closed, and the fix has been released in candlepin-2.10.0-1 (current master). This will be included in Sat 6.8

Comment 9 Lai 2020-06-17 18:54:46 UTC
Steps to retest:

1. ssh into satellite
2. Run command: su - postgres -c "psql -d candlepin -c 'SELECT indrelid::regclass AS TableName,array_agg(indexrelid::regclass) AS Indexes FROM pg_index GROUP BY indrelid,indkey HAVING COUNT(*) > 1;;'"

Expected result:
o duplicates in db

Actual result:
 tablename | indexes 
-----------+---------
(0 rows)

Verified on 6.7.0_05.

I've already checked using su - postgres -c "psql -d candlepin -c 'SELECT indrelid::regclass AS TableName,array_agg(indexrelid::regclass) AS Indexes FROM pg_index GROUP BY indrelid,indkey;;'" and saw that there's no duplicate.

Comment 12 errata-xmlrpc 2020-10-27 12:59:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: Satellite 6.8 release), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:4366