Project

General

Profile

Bug #33936

Upgrade fails with PG::NotNullViolation: ERROR: column "subscription_id" contains null values

Added by Jonathon Turel 2 months ago. Updated 6 days ago.

Status:
Closed
Priority:
Normal
Category:
Upgrades
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:

Description

How reproducible:
- When running foreman-rake db:migrate

foreman=# select id,subscription_id from katello_pools where subscription_id IS null;
- returns 63 rows with subscription_id that has a null value

Full trace: ###########
[root@satellite6:/root]# foreman-rake db:migrate --trace
'ErbParser' is ignored.
'RubyParser' is ignored.
  • Invoke db:migrate (first_time)
  • Invoke db:load_config (first_time)
  • Invoke environment (first_time)
  • Execute environment
    API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
  • Execute db:load_config
  • Invoke plugin:refresh_migrations (first_time)
  • Invoke environment
  • Execute plugin:refresh_migrations
  • Execute db:migrate
    20210331180353 KatelloPoolOrganizationIdNotNullable: migrating ===========
    -- change_column(:katello_pools, :organization_id, :integer, {:null=>false})
    > 0.0023s
    -
    change_column(:katello_pools, :subscription_id, :integer, {:null=>false})
    rake aborted!
    StandardError: An error has occurred, this and all later migrations canceled:
PG::NotNullViolation: ERROR:  column "subscription_id" contains null values
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `async_exec'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:92:in `block (2 levels) in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:91:in `block in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:722:in `block (2 levels) in log'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:721:in `block in log'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.3.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract_adapter.rb:712:in `log'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/database_statements.rb:90:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/postgresql/schema_statements.rb:402:in `change_column'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:890:in `block in method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `block in say_with_time'
/opt/rh/rh-ruby27/root/usr/share/ruby/benchmark.rb:293:in `measure'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:858:in `say_with_time'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:879:in `method_missing'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.1.1.35/db/migrate/20210331180353_katello_pool_organization_id_not_nullable.rb:5:in `up'

Associated revisions

Revision a8a75800 (diff)
Added by Jonathon Turel 2 months ago

Fixes #33936 - Delete Pools with null subscription_id before adding not-null constraint

History

#1 Updated by Jonathon Turel 2 months ago

  • Target version changed from Katello 4.4.0 to Katello 4.3.0
  • Subject changed from Upgrade fails with PG::NotNullViolation: ERROR: column "subscription_id" contains null values to Upgrade fails with PG::NotNullViolation: ERROR: column "subscription_id" contains null values

#2 Updated by The Foreman Bot 2 months ago

  • Assignee set to Jonathon Turel
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/9791 added

#3 Updated by James Jeffers 2 months ago

  • Target version changed from Katello 4.3.0 to Katello 4.2.2

#4 Updated by James Jeffers 2 months ago

  • Triaged changed from No to Yes

#5 Updated by The Foreman Bot 2 months ago

  • Fixed in Releases Katello 4.4.0 added

#6 Updated by Jonathon Turel 2 months ago

  • Status changed from Ready For Testing to Closed

#7 Updated by The Foreman Bot 6 days ago

  • Pull request https://github.com/Katello/katello/pull/9890 added

Also available in: Atom PDF