Bug 1015155 - upgrade to SAM 1.3 fails due to FK constraint violation on activation_keys_user_id_fk
upgrade to SAM 1.3 fails due to FK constraint violation on activation_keys_us...
Status: CLOSED ERRATA
Product: Subscription Asset Manager
Classification: Red Hat
Component: katello (Show other bugs)
1.3
Unspecified Unspecified
unspecified Severity urgent
: rc
: ---
Assigned To: Tom McKay
sthirugn@redhat.com
:
Depends On:
Blocks: 1018381
  Show dependency treegraph
 
Reported: 2013-10-03 10:26 EDT by Shannon Hughes
Modified: 2013-10-16 20:46 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1018381 (view as bug list)
Environment:
Last Closed: 2013-10-08 14:58:30 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
katello_upgrade.log (84.28 KB, text/x-log)
2013-10-03 11:23 EDT, Kyle Benson
no flags Details


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 505483 None None None Never

  None (edit)
Description Shannon Hughes 2013-10-03 10:26:13 EDT
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 11:23:11 EDT
Created attachment 807146 [details]
katello_upgrade.log

Attached log of failed upgrade
Comment 4 sthirugn@redhat.com 2013-10-04 16:21:16 EDT
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 14:58:30 EDT
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-16 20:46:05 EDT
Added Red Hat KCS Solution as external tracker:
https://access.redhat.com/site/solutions/505483

Note You need to log in before you can comment on or make changes to this bug.