Bug 998631

Summary: SAM 1.3 upgrade fails with a foreign key constraint error
Product: [Retired] Subscription Asset Manager Reporter: sthirugn <sthirugn>
Component: katelloAssignee: Tom McKay <tomckay>
Status: CLOSED ERRATA QA Contact: sthirugn <sthirugn>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.3CC: bkearney, tomckay
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-10-01 11:20:28 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:    
Bug Blocks: 833466    
Attachments:
Description Flags
katello-debug
none
katello-upgrade output none

Description sthirugn@redhat.com 2013-08-19 16:06:05 UTC
Description of problem:
SAM 1.3 upgrade fails with a foreign key constraint error

Version-Release number of selected component (if applicable):
* candlepin-0.8.20-1.el6sam.noarch
* candlepin-cert-consumer-cloud-qe-21.idm.lab.bos.redhat.com-1.0-1.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.8.20-1.el6sam.noarch
* candlepin-tomcat6-0.8.20-1.el6sam.noarch
* elasticsearch-0.19.9-8.el6sat.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.4.2-2.el6sat.noarch
* katello-cli-1.4.3-7.el6sat.noarch
* katello-cli-common-1.4.3-7.el6sat.noarch
* katello-common-1.4.3-8.el6sam_splice.noarch
* katello-configure-1.4.4-2.el6sat.noarch
* katello-glue-candlepin-1.4.3-8.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-8.el6sam_splice.noarch
* katello-headpin-1.4.3-8.el6sam_splice.noarch
* katello-headpin-all-1.4.3-8.el6sam_splice.noarch
* katello-selinux-1.4.4-2.el6sat.noarch
* thumbslug-0.0.32-1.el6sam.noarch
* thumbslug-selinux-0.0.32-1.el6sam.noarch

How reproducible:
Always

Steps to Reproduce:
1. Install SAM 1.2.1 from RHN
2. Upgrade to SAM 1.3
-> Create a SAM 1.3 repo
-> #yum upgrade
-> #katello-upgrade

Actual results:
Upgrade failed (katello-upgrade stdout statements and katello-debug statements attached)

/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in `async_exec': PGError: ERROR:  update or delete on table "task_statuses" violates foreign key constraint "providers_task_status_id_fk" on table "providers" (ActiveRecord::InvalidForeignKey)
DETAIL:  Key (id)=(1) is still referenced from table "providers".
: DELETE FROM "task_statuses"
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in `exec_no_cache'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:675:in `block in exec_delete'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:674:in `exec_delete'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:101:in `delete'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `delete'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/relation.rb:413:in `delete_all'
	from /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/querying.rb:7:in `delete_all'
	from /usr/share/katello/install/upgrade-scripts/0711_delete_task_statuses.runner:13:in `<top (required)>'
	from /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/runner.rb:51:in `eval'
	from /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands/runner.rb:51:in `<top (required)>'
	from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
	from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
	from /opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:64:in `<top (required)>'
	from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
	from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
	from /usr/share/katello//script/rails:50:in `<main>'
	from caused by: (PGError) ERROR:  update or delete on table "task_statuses" violates foreign key constraint "providers_task_status_id_fk" on table "providers"
DETAIL:  Key (id)=(1) is still referenced from table "providers".

Expected results:
Upgrade passed

Additional info:

Comment 1 sthirugn@redhat.com 2013-08-19 16:06:31 UTC
Created attachment 788146 [details]
katello-debug

Comment 2 sthirugn@redhat.com 2013-08-19 16:07:18 UTC
Created attachment 788147 [details]
katello-upgrade output

Comment 4 Tom McKay 2013-08-20 13:43:15 UTC
Branch: refs/heads/master
  Home:   https://github.com/Katello/katello-installer
  Commit: dddaa9d1e5c28671bd65fb7b4633b729106ea6e5
      https://github.com/Katello/katello-installer/commit/dddaa9d1e5c28671bd65fb7b4633b729106ea6e5
  Author: Tom McKay <thomasmckay>
  Date:   2013-08-20 (Tue, 20 Aug 2013)

Comment 6 sthirugn@redhat.com 2013-08-26 23:28:10 UTC
VERIFIED.

I did not see the foreign key constraint error this time.

Version tested:
* candlepin-0.8.21-1.el6sam.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.8.21-1.el6sam.noarch
* candlepin-tomcat6-0.8.21-1.el6sam.noarch
* elasticsearch-0.19.9-8.el6sat.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.4.2-2.el6sat.noarch
* katello-cli-1.4.3-8.el6sat.noarch
* katello-cli-common-1.4.3-8.el6sat.noarch
* katello-common-1.4.3-9.el6sam_splice.noarch
* katello-configure-1.4.4-3.el6sat.noarch
* katello-glue-candlepin-1.4.3-9.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-9.el6sam_splice.noarch
* katello-headpin-1.4.3-9.el6sam_splice.noarch
* katello-headpin-all-1.4.3-9.el6sam_splice.noarch
* katello-selinux-1.4.4-2.el6sat.noarch
* thumbslug-0.0.32-1.el6sam.noarch
* thumbslug-selinux-0.0.32-1.el6sam.noarch

Comment 8 errata-xmlrpc 2013-10-01 11:20:28 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHEA-2013-1390.html