Bug 1015155

Summary: upgrade to SAM 1.3 fails due to FK constraint violation on activation_keys_user_id_fk
Product: [Retired] Subscription Asset Manager Reporter: Shannon Hughes <shughes>
Component: katelloAssignee: Tom McKay <tomckay>
Status: CLOSED ERRATA QA Contact: sthirugn <sthirugn>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 1.3CC: bkearney, kbenson, sthirugn, tomckay, xdmoon
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1018381 (view as bug list) Environment:
Last Closed: 2013-10-08 18:58:30 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: 1018381    
Attachments:
Description Flags
katello_upgrade.log none

Description Shannon Hughes 2013-10-03 14:26:13 UTC
Description of problem:

Customer is hitting issue with their SAM 1.3 upgrade. The schema upgrade is failing trying to create a FK constraint. Looks like an id is not avialable in the users table, 

10/02/13 12:25:56 PGError: ERROR:  insert or update on table "activation_keys" violates foreign key constraint "activation_keys_user_id_fk"
10/02/13 12:25:56 DETAIL:  Key (user_id)=(9) is not present in table "users".
10/02/13 12:25:56 : ALTER TABLE "activation_keys" ADD CONSTRAINT "activation_keys_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "users"(id) INITIALLY DEFERRED
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `async_exec'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:654:in `block in execute'
10/02/13 12:25:56 /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'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:653:in `execute'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/foreigner-1.4.1/lib/foreigner/connection_adapters/sql2003.rb:19:in `add_foreign_key'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:466:in `block in method_missing'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:438:in `block in say_with_time'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/ruby/benchmark.rb:280:in `measure'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:438:in `say_with_time'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:458:in `method_missing'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:334:in `method_missing'
10/02/13 12:25:56 /usr/share/katello/db/migrate/20130613090036_add_foreign_keys.rb:5:in `add_foreign_key_deferred'
10/02/13 12:25:56 /usr/share/katello/db/migrate/20130613090036_add_foreign_keys.rb:29:in `up'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:370:in `up'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/ruby/benchmark.rb:280:in `measure'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:410:in `block in migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:123:in `with_connection'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:389:in `migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:528:in `migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:775:in `call'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:775:in `block in ddl_transaction'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/transactions.rb:208:in `transaction'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:775:in `ddl_transaction'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:719:in `block in migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `each'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:700:in `migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:570:in `up'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/migration.rb:551:in `migrate'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:153:in `block (2 levels) in <top (required)>'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/share/gems/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/bin/rake:23:in `load'
10/02/13 12:25:56 /opt/rh/ruby193/root/usr/bin/rake:23:in `<main>'
10/02/13 12:25:56 caused by: (PGError) ERROR:  insert or update on table "activation_keys" violates foreign key constraint "activation_keys_user_id_fk"
10/02/13 12:25:56 DETAIL:  Key (user_id)=(9) is not present in table "users".
10/02/13 12:25:56
10/02/13 12:25:56     ... skipped 54 lines
10/02/13 12:25:56 caused by: (ActiveRecord::InvalidForeignKey) PGError: ERROR:  insert or update on table "activation_keys" violates foreign key constraint "activation_keys_user_id_fk"

looks like the upgrade script is 20130613090036_add_foreign_keys.rb 

will ask kbenson to attach logs

Comment 1 Kyle Benson 2013-10-03 15:23:11 UTC
Created attachment 807146 [details]
katello_upgrade.log

Attached log of failed upgrade

Comment 4 sthirugn@redhat.com 2013-10-04 20:21:16 UTC
VERIFIED.

Version Tested:
* candlepin-0.8.26-1.el6sam.noarch
* candlepin-cert-consumer-sgi-uv20-01.rhts.eng.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.26-1.el6sam.noarch
* candlepin-tomcat6-0.8.26-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-11.el6sat.noarch
* katello-cli-common-1.4.3-11.el6sat.noarch
* katello-common-1.4.3.19-1.el6sam_splice.noarch
* katello-configure-1.4.4-5.el6sam.noarch
* katello-glue-candlepin-1.4.3.19-1.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3.19-1.el6sam_splice.noarch
* katello-headpin-1.4.3.19-1.el6sam_splice.noarch
* katello-headpin-all-1.4.3.19-1.el6sam_splice.noarch
* katello-selinux-1.4.4-2.el6sat.noarch
* thumbslug-0.0.34-1.el6sam.noarch
* thumbslug-selinux-0.0.34-1.el6sam.noarch

Comment 6 errata-xmlrpc 2013-10-08 18:58:30 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/RHBA-2013-1412.html

Comment 8 Kyle Benson 2013-10-17 00:46:05 UTC
Added Red Hat KCS Solution as external tracker:
https://access.redhat.com/site/solutions/505483