Uploaded image for project: 'Satellite'
  1. Satellite
  2. SAT-24910

Possible DB deadlock when publishing a content view with many similar contents

XMLWordPrintable

    • 3
    • False
    • Moderate
    • Artemis Prioritized Backlog
    • sat-artemis
    • None
    • None
    • None
    • No Coverage
    • No

      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}

      ~~~

              Unassigned Unassigned
              rhn-support-hyu Hao Chang Yu
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: