Project

General

Profile

Actions

Bug #23942

closed

Error deleting manifest. PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"

Added by Jonathon Turel almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Subscriptions
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1581700

Description of problem: Trying to delete manifest after upgrade to satellite 6.4 snap 4 from satellite 6.3.1, gives error Error deleting manifest. PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id" DETAIL: Key (cp_id)=(8a88f7815e22b340015e22bc74ea0196) already exists. : INSERT INTO "katello_pools" ("cp_id", "created_at", "updated_at", "organization_id") VALUES ($1, $2, $3, $4) RETURNING "id"

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

How reproducible: always

Steps to Reproduce:
1. Upgrade satellite to 6.4 snap 4
2. Upload manifest
3. Try to delete manifest

Actual results:

Error deleting manifest. PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"

and production.log showed

2018-05-23T08:25:31 [W|app|f29fc] Orphaned Product id 883 found while refreshing/importing manifest.
2018-05-23T08:25:31 [W|app|f29fc] Orphaned Product id 882 found while refreshing/importing manifest.
2018-05-23T08:25:31 [W|app|f29fc] Orphaned Product id 881 found while refreshing/importing manifest.
2018-05-23T08:25:31 [W|app|f29fc] Orphaned Product id 880 found while refreshing/importing manifest.
2018-05-23T08:25:31 [W|app|f29fc] Orphaned Product id 879 found while refreshing/importing manifest.
2018-05-23T08:25:31 [W|app|f29fc] Orphaned Product id 878 found while refreshing/importing manifest.
2018-05-23T08:25:34 [I|aud|] update event for Organization with id 36
2018-05-23T08:30:15 [E|bac|] PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"
DETAIL: Key (cp_id)=(8a88f7815e22b340015e22bc74ea0196) already exists.
: INSERT INTO "katello_pools" ("cp_id", "created_at", "updated_at", "organization_id") VALUES ($1, $2, $3, $4) RETURNING "id" (ActiveRecord::RecordNotUnique)
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `async_exec'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:614:in `block (2 levels) in exec_no_cache'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:613:in `block in exec_no_cache'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
/opt/rh/rh-ruby24/root/usr/share/ruby/monitor.rb:214:in `mon_synchronize'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:612:in `exec_no_cache'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:601:in `execute_and_clear'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:79:in `exec_query'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:102:in `exec_insert'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:113:in `exec_insert'
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract/database_statements.rb:133:in `insert'

Expected results: Manifest delete success.

Additional info:

Actions #1

Updated by Jonathon Turel almost 6 years ago

  • translation missing: en.field_release set to 338
Actions #2

Updated by Partha Aji almost 6 years ago

  • Triaged set to No

The ::Katello::Pool model changed between 3.6 and 3.7 due to the Candlepin 2.2 -> 2.3 migration. However the migration script does not properly reset the column information after associating the organization to the Pool. This causes all sorts of foreign key violation errors like
"Error deleting manifest. PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_katello_pools_on_cp_id"" when re indexing stuff from candlepin

I believe this issue and the upgrade errors that we got when running -> https://github.com/theforeman/forklift/blob/master/pipelines/pipeline_katello_36_to_37_upgrade.yml are related to the same cause

Actions #3

Updated by The Foreman Bot almost 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/7507 added
Actions #4

Updated by Partha Aji almost 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #5

Updated by Brad Buckingham almost 6 years ago

  • Target version set to Katello 3.7.0
Actions #6

Updated by Alain Deléglise almost 6 years ago

Hello,

I'm encountering the same issue on my Katello 3.6, running on CentOS 7.

I've followed all the mentionned steps in the upgrade docs. I'm now blocked at the foreman-rake katello:import_subscriptions task.

I've tried to update katello today, so I'm using the newest packages in the repos.

This bug will be corrected in the final 3.7 version ?

Actions #7

Updated by Jonathon Turel almost 6 years ago

Hello Alain,

This will indeed be fixed in Katello 3.7, however I wonder if you are actually hitting this same issue. I wonder that because the fix here only affects 3.7 RC1. Would you mind providing a stack trace?

Actions #8

Updated by Alain Deléglise almost 6 years ago

Thanks for your answer.

I was trying to upgrade to the current 3.7 RC1 version. However I can't give you a stack as we've restored the full VM backup which was in 3.6. Now we're struggling with a new problem (Katello::Resources::Candlepin::Owner: 404 Not Found) and I don't know if we're going to try the upgrade to the RC1.

The system will soon be in production, and I think we'll wait for the final 3.7 version.

Actions

Also available in: Atom PDF