Upgrade of Red Hat Satellite 6 fails during a database migration

Solution Verified - Updated

Environment

  • Red Hat Satellite 6

Issue

  • Red Hat Satellite 6.7 upgrade fails with following error :

       Upgrade Step: migrate_foreman...
    /usr/share/foreman/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
    /usr/share/foreman/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
    /usr/share/foreman/lib/core_extensions.rb:182: warning: already initialized constant ActiveSupport::MessageEncryptor::DEFAULT_CIPHER
    /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/message_encryptor.rb:22: warning: previous definition of DEFAULT_CIPHER was here
    API controllers newer than Apipie cache! Run apipie:cache rake task to regenerate cache.
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.59/app/models/katello/concerns/content_facet_host_extensions.rb:7: warning: already initialized constant Katello::Concerns::ContentFacetHostExtensions::ERRATA_STATUS_MAP
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.59/app/models/katello/concerns/content_facet_host_extensions.rb:7: warning: previous definition of ERRATA_STATUS_MAP was here
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.59/app/models/katello/concerns/content_facet_host_extensions.rb:14: warning: already initialized constant Katello::Concerns::ContentFacetHostExtensions::TRACE_STATUS_MAP
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.59/app/models/katello/concerns/content_facet_host_extensions.rb:14: warning: previous definition of TRACE_STATUS_MAP was here
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.59/app/models/katello/concerns/subscription_facet_host_extensions.rb:13: warning: already initialized constant Katello::Concerns::SubscriptionFacetHostExtensions::SUBSCRIPTION_STATUS_MAP
    /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.7.0.59/app/models/katello/concerns/subscription_facet_host_extensions.rb:13: warning: previous definition of SUBSCRIPTION_STATUS_MAP was here
    rake aborted!
    StandardError: An error has occurred, this and all later migrations canceled:
    PG::InternalError: ERROR:  right sibling's left-link doesn't match: block 6 links to 184 instead of expected 5 in index "index_audits_on_id"
    : UPDATE "audits" SET "auditable_type" = 'Host::Base' WHERE "audits"."auditable_type" = $1
    /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib /active_record/connection_adapters/postgresql_adapter.rb:616:in `async_exec'
    

Resolution

1. As a best practice, if it's a physical server take a full backup of Red Hat Satellite host or take snapshot backup if running on the virtual machine before applying/updating below configuration change on the satellite server.

2. Correct index audit table.

  # echo "reindex table audits"|su - postgres -c "psql foreman"

3. Restart Foreman service.

  # foreman-maintain service restart

4. Re-run the upgrade.

  # satellite-installer --scenario satellite --upgrade -v

Note: To skip yum update and to keep satellite on same installed version using satellite-installer instead of foreman-maintain.

For more KB articles/solutions related to Red Hat Satellite 6.x Installation/Upgrade/Update Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Installation/Upgrade/Update Issues.

Root Cause

  • The issue is caused while attempting to upgrade Red Hat Satellite where the Satellite package is manually installed and db:migrate is unable to complete.

Diagnostic Steps

  • /var/log/foreman-installer/satellite.log shows following error

    rake aborted!
    StandardError: An error has occurred, this and all later migrations canceled:
    PG::InternalError: ERROR:  right sibling's left-link doesn't match: block 6 links to 184 instead of expected 5 in index "index_audits_on_id"
    UPDATE "audits" SET "auditable_type" = 'Host::Base' WHERE "audits"."auditable_type" = $1
    /opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activerecord-5.1.6/lib/active_record/connection_adapters/postgresql_adapter.rb:616:in  async_exec'
    
SBR
Product(s)
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.