Bug 2278795

Summary: Possible DB deadlock when publishing a content view with many similar contents
Product: Red Hat Satellite Reporter: Hao Chang Yu <hyu>
Component: Content ViewsAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED MIGRATED QA Contact: Satellite QE Team <sat-qe-bz-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.14.4CC: ajambhul, jbhatia, rlavi
Target Milestone: UnspecifiedKeywords: MigratedToJIRA, Performance, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-06 17:36:35 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:

Description Hao Chang Yu 2024-05-03 05:55:22 UTC
Description of problem:
This bug had been raised before in bug 2252297 but it was closed because it is hard to reproduce. Thus, I raise a new one for it.

The deadlock error happens when indexing contents of multiple repositories with many similar contents. This could be happened when publishing a content view (in index contents step) with those repositories. For example, RHEL 8 BaseOs and RHEL 8.x BaseOs repos

Steps to reproduce:
1. Create a content view
2. Add RHEL 8 BaseOs repo and multiple many RHEL 8.x BaseOs repositories to the content view.
3. Publish the content view.

Actual results:
ActiveRecord::Deadlocked (PG::TRDeadlockDetected: ERROR:  deadlock detected)
DETAIL:  Process 361390 waits for ShareLock on transaction 85433497; blocked by process 361035.
Process 361035 waits for ShareLock on transaction 85433498; blocked by process 361390.
HINT:  See server log for query details.
CONTEXT:  while inserting index tuple (1530,1) in relation "katello_errata"

Expected results
No Error


Additional info:
The reproducing steps might above might have low chance to reproduce the deadlock error. The higher chance I found is open multiple terminals and run the index errata concurrently.

For example:

Terminal 1:
~~~
Setting[:bulk_load_size] = 250
repo = Katello::ContentView.find(30).versions.last.archived_repos.where("relative_path ilike ?", '%baseos%').sort_by(&:id).first
type = repo.root.repository_type.content_types_to_index.find{|t| t.content_type == 'erratum'}
10.times {Katello::ContentUnitIndexer.new(content_type: type, repository: repo, optimized: false).import_all; sleep 1}
~~~

Terminal 2:
~~~
Setting[:bulk_load_size] = 250
repo = Katello::ContentView.find(30).versions.last.archived_repos.where("relative_path ilike ?", '%baseos%').sort_by(&:id).second
type = repo.root.repository_type.content_types_to_index.find{|t| t.content_type == 'erratum'}
10.times {Katello::ContentUnitIndexer.new(content_type: type, repository: repo, optimized: false).import_all; sleep 1}
~~~

Terminal 3:
~~~
Setting[:bulk_load_size] = 250
repo = Katello::ContentView.find(30).versions.last.archived_repos.where("relative_path ilike ?", '%baseos%').sort_by(&:id).third
type = repo.root.repository_type.content_types_to_index.find{|t| t.content_type == 'erratum'}
10.times {Katello::ContentUnitIndexer.new(content_type: type, repository: repo, optimized: false).import_all; sleep 1}
~~~

Comment 1 Eric Helms 2024-06-06 17:36:35 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "SAT-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.