Bug 2052420 - Satellite upgrade fails during db:migrate with PG::DuplicateTable: ERROR: relation "index_hostgroups_puppetclasses_on_hostgroup_id" already exists
Summary: Satellite upgrade fails during db:migrate with PG::DuplicateTable: ERROR: re...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Puppet
Version: 6.11.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: 6.11.0
Assignee: satellite6-bugs
QA Contact: Lukas Pramuk
URL:
Whiteboard:
Depends On:
Blocks: 2029760
TreeView+ depends on / blocked
 
Reported: 2022-02-09 09:03 UTC by Lukas Pramuk
Modified: 2022-07-05 14:33 UTC (History)
5 users (show)

Fixed In Version: tfm-rubygem-foreman_puppet-2.0.3
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-07-05 14:32:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github theforeman foreman_puppet issues 246 0 None closed Migration fails for upgrades 2022-02-09 09:22:12 UTC
Red Hat Product Errata RHSA-2022:5498 0 None None None 2022-07-05 14:33:06 UTC

Description Lukas Pramuk 2022-02-09 09:03:39 UTC
Description of problem:
Satellite upgrade from 6.10.2 (and 6.10.1) to 7.0 fails during db:migrate with PG::DuplicateTable: ERROR:  relation "index_hostgroups_puppetclasses_on_hostgroup_id" already exists

QE populated Satellite was used.


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


How reproducible:
deterministic


Steps to Reproduce:
1. Have a QE populated and registered Satellite 6.10.2  
2. Upgrade to 7.0.0

# satellite-maintain upgrade run --target-version 7.0 -w repositories-validate,repositories-setup -y
...

Running Migration scripts to Satellite 7.0
================================================================================
Setup repositories:                                                   [ALREADY RUN]
The step was skipped as it was already run and it is marked as run_once. Use --force to enforce the execution.
--------------------------------------------------------------------------------
Unlock packages:                                                      [OK]
--------------------------------------------------------------------------------
Update package(s) :                                                   [OK]
--------------------------------------------------------------------------------
Procedures::Installer::Upgrade:                                       [FAIL]
Failed executing LANG=en_US.utf-8 satellite-installer  --disable-system-checks, exit status 6:
 2022-02-09 02:46:25 [NOTICE] [root] Loading installer configuration. This will take some time.
2022-02-09 02:46:32 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2022-02-09 02:46:32 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2022-02-09 02:46:39 [WARN  ] [pre] Skipping system checks.
2022-02-09 02:46:39 [WARN  ] [pre] Skipping system checks.
2022-02-09 02:46:52 [NOTICE] [configure] Starting system configuration.
2022-02-09 02:47:08 [NOTICE] [configure] 250 configuration steps out of 2152 steps complete.
2022-02-09 02:47:29 [NOTICE] [configure] 500 configuration steps out of 2156 steps complete.
2022-02-09 02:47:43 [NOTICE] [configure] 750 configuration steps out of 2158 steps complete.
2022-02-09 02:47:54 [NOTICE] [configure] 1000 configuration steps out of 2163 steps complete.
2022-02-09 02:48:10 [NOTICE] [configure] 1250 configuration steps out of 2181 steps complete.
2022-02-09 02:49:14 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-02-09 02:49:14 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns: change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-02-09 02:50:08 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: Failed to call refresh: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-02-09 02:50:08 [ERROR ] [configure] /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2022-02-09 02:50:36 [NOTICE] [configure] 1500 configuration steps out of 2182 steps complete.
2022-02-09 02:50:40 [NOTICE] [configure] 1750 configuration steps out of 3026 steps complete.
2022-02-09 02:50:40 [NOTICE] [configure] 2000 configuration steps out of 3026 steps complete.
2022-02-09 02:50:41 [NOTICE] [configure] 2250 configuration steps out of 3026 steps complete.
2022-02-09 02:50:41 [NOTICE] [configure] 2500 configuration steps out of 3026 steps complete.
2022-02-09 02:51:02 [NOTICE] [configure] 2750 configuration steps out of 3026 steps complete.
2022-02-09 02:51:48 [NOTICE] [configure] 3000 configuration steps out of 3026 steps complete.
2022-02-09 02:51:57 [NOTICE] [configure] System configuration has finished.


Actual results:
failed upgrade due to failing db:migrate

Expected results:
successful upgrade

Comment 1 Lukas Pramuk 2022-02-09 09:05:00 UTC
# foreman-rake db:migrate
'ErbParser' is ignored.
'RubyParser' is ignored.
API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
== 20090905150132 CreateHostgroupsPuppetclasses: migrating ====================
-- create_table(:hostgroups_puppetclasses, {:id=>false, :if_not_exists=>true})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "index_hostgroups_puppetclasses_on_hostgroup_id" already exists
/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:443:in `add_index'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:319:in `block in create_table'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/schema_statements.rb:318:in `create_table'
/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/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/foreman_puppet-2.0.2/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb:3:in `up'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:831:in `exec_migration'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:812:in `block (2 levels) in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:811:in `block in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:471:in `with_connection'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:810:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1002:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1310:in `block in execute_migration_in_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `block in ddl_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `block in transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
/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/transaction.rb:278:in `within_new_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/connection_adapters/abstract/database_statements.rb:280:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/transactions.rb:212:in `transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1361:in `ddl_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1309:in `execute_migration_in_transaction'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1281:in `block in migrate_without_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1280:in `migrate_without_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `block in migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1382:in `with_advisory_lock'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1229:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1061:in `up'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/migration.rb:1036:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/tasks/database_tasks.rb:238:in `migrate'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:86:in `block (3 levels) in <top (required)>'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `each'
/opt/theforeman/tfm/root/usr/share/gems/gems/activerecord-6.0.3.7/lib/active_record/railties/databases.rake:84:in `block (2 levels) in <top (required)>'
/opt/rh/rh-ruby27/root/usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
...

Comment 2 Brad Buckingham 2022-02-09 20:54:52 UTC
Hi Ondrej,

Does the PR that was associated with the bug the solution?

If so, we can probably move this one to POST.  (Asking as automation won't transition it, as that is based upon redmine).

Thanks!

Comment 3 Ondřej Ezr 2022-02-11 09:38:25 UTC
Yes the PR is a solution and now it's already released in foreman_puppet 2.0.3 :)

Comment 7 Lukas Pramuk 2022-02-23 09:45:20 UTC
VERIFIED.

@Satellite 7.0.0 Snap10
tfm-rubygem-foreman_puppet-2.0.3-1.el7sat.noarch

Although Satellite upgrade failed at db:migrate step (due to another BZ 2053970) you are still able to check what DB migration passed successfully

# foreman-rake db:migrate:status |grep -C10 20090905150132
'ErbParser' is ignored.
'RubyParser' is ignored.
   up     20090718064254  Create subnets
   up     20090720134126  Create operatingsystems
   up     20090722140138  Create models
   up     20090722141107  Create environmentsforeman puppet
   up     20090729132209  Create reports
   up     20090730152224  Create ptables
   up     20090802062223  Create puppetclassesforeman puppet
   up     20090804130144  Create parameters
   up     20090820130541  Create auth sources
   up     20090905150131  Create hostgroups
   up     20090905150132  Create hostgroups puppetclassesforeman puppet   <- passed successfully ("up")
   up     20090905155444  Add type to parameter
   up     20090907045751  Add domain to parameter
   up     20090915030726  Change report field type to text
   up     20090916053824  Change host build default to false
   up     20090920043521  Add index to host
   up     20090920064156  Add index to parameters
   up     20090920065522  Add index to reports
   up     20091012135004  Create users
   up     20091016031017  Create sessions
   up     20091022054108  Add status to report

>>> 20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb migration is now passing successfully

Comment 13 errata-xmlrpc 2022-07-05 14:32:53 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 (Moderate: Satellite 6.11 Release), and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHSA-2022:5498


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