Upgrade to 3.9 failed - foreman-rake db:migrate returned 1 instead of one of [0]

Problem:
Following steps for 3.8 → 3.9 upgrade, foreman-installer --scenario katello fails due to change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]

Expected outcome:
Upgrade goes smoothly

Foreman and Proxy versions:
Target versions:

[root@foreman ~]# rpm -qa | grep -i 'foreman\|foreman-proxy' | grep -v rubygem
foreman-service-3.9.3-1.el8.noarch
foreman-debug-3.9.3-1.el8.noarch
foreman-redis-3.9.3-1.el8.noarch
foreman-proxy-3.9.3-1.el8.noarch
foreman-release-3.9.3-1.el8.noarch
foreman-obsolete-packages-1.6-1.el8.noarch
foreman-installer-katello-3.9.3-1.el8.noarch
foreman-3.9.3-1.el8.noarch
foreman-dynflow-sidekiq-3.9.3-1.el8.noarch
foreman-postgresql-3.9.3-1.el8.noarch
foreman-installer-3.9.3-1.el8.noarch
foreman-cli-3.9.3-1.el8.noarch
foreman-selinux-3.9.3-1.el8.noarch

Foreman and Proxy plugin versions:

Distribution and version:

[root@foreman ~]# cat /etc/os-release
NAME="AlmaLinux"
VERSION="8.10 (Cerulean Leopard)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.10"
PLATFORM_ID="platform:el8"
PRETTY_NAME="AlmaLinux 8.10 (Cerulean Leopard)"

Other relevant data:
Running foreman-installer --scenario katello on step 14 gives the following output:
https://docs.theforeman.org/3.9/Upgrading_Project/index-katello.html

[root@foreman ~]# foreman-installer --scenario katello
2024-08-07 12:28:46 [WARN  ] [boot] <Array> ["Unsetting environment variable 'http_proxy' for the duration of the install."]
2024-08-07 12:28:46 [WARN  ] [boot] <Array> ["Unsetting environment variable 'https_proxy' for the duration of the install."]
2024-08-07 12:28:47 [NOTICE] [root] Loading installer configuration. This will take some time.
2024-08-07 12:28:55 [NOTICE] [root] Running installer with log based terminal output at level NOTICE.
2024-08-07 12:28:55 [NOTICE] [root] Use -l to set the terminal output log level to ERROR, WARN, NOTICE, INFO, or DEBUG. See --full-help for definitions.
2024-08-07 12:29:07 [NOTICE] [configure] Starting system configuration.
2024-08-07 12:29:33 [NOTICE] [configure] 250 configuration steps out of 1921 steps complete.
2024-08-07 12:29:38 [NOTICE] [configure] 500 configuration steps out of 1922 steps complete.
2024-08-07 12:29:46 [NOTICE] [configure] 750 configuration steps out of 1926 steps complete.
2024-08-07 12:29:47 [NOTICE] [configure] 1000 configuration steps out of 1932 steps complete.
2024-08-07 12:29:48 [NOTICE] [configure] 1250 configuration steps out of 1933 steps complete.
2024-08-07 12:30:05 [NOTICE] [configure] 1500 configuration steps out of 1933 steps complete.
2024-08-07 12:31:02 [ERROR ] [configure] '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
2024-08-07 12:31:02 [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]
2024-08-07 12:31:31 [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]
2024-08-07 12:31:31 [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]
2024-08-07 12:31:46 [NOTICE] [configure] 1750 configuration steps out of 1933 steps complete.
2024-08-07 12:33:32 [NOTICE] [configure] System configuration has finished.

Error 1: Puppet Exec resource 'foreman-rake-db:migrate' failed. Logs:
  /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]
    Adding autorequire relationship with User[foreman]
    Starting to evaluate the resource (1667 of 1933)
    Failed to call refresh: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
    '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
    Evaluated in 59.65 seconds
  Exec[foreman-rake-db:migrate](provider=posix)
    Executing check '/usr/sbin/foreman-rake db:abort_if_pending_migrations'
    Executing '/usr/sbin/foreman-rake db:migrate'
    Executing check '/usr/sbin/foreman-rake db:abort_if_pending_migrations'
    Executing '/usr/sbin/foreman-rake db:migrate'
  /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/unless
    rake aborted!
    Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `new'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `connect_addrinfo'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:193:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each_with_index'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:305:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:385:in `establish_connection'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:117:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:344:in `with_reconnect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:116:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:417:in `ensure_connected'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:269:in `block in process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:356:in `logging'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:268:in `process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:162:in `call'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:564:in `block in del'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `block in synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:563:in `del'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block (2 levels) in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:25:in `with'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:478:in `failsafe'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:417:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/strategy/local_cache.rb:170:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:487:in `block in delete'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `block in instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:205:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:486:in `delete'
    /usr/share/foreman/app/services/topbar_sweeper.rb:18:in `block in expire_cache_all_users'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `each'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `expire_cache_all_users'
    /usr/share/foreman/config/initializers/foreman.rb:35:in `block in <top (required)>'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `instance_exec'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `block in make_lambda'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `catch'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `block in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:199:in `block in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `block in invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `each'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:105:in `run_callbacks'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/reloader.rb:88:in `prepare!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `instance_exec'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `block in run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `run'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:61:in `block in run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:60:in `run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:391:in `initialize!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `public_send'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `method_missing'
    /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
    /usr/share/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    /usr/share/gems/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `block in require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:299:in `load_dependency'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `require'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:367:in `require_environment!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
    /usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
    Tasks: TOP => db:abort_if_pending_migrations => db:load_config => environment
    (See full trace by running task with --trace)
    rake aborted!
    Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `new'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `connect_addrinfo'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:193:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each_with_index'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:305:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:385:in `establish_connection'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:117:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:344:in `with_reconnect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:116:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:417:in `ensure_connected'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:269:in `block in process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:356:in `logging'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:268:in `process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:162:in `call'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:564:in `block in del'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `block in synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:563:in `del'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block (2 levels) in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:25:in `with'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:478:in `failsafe'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:417:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/strategy/local_cache.rb:170:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:487:in `block in delete'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `block in instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:205:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:486:in `delete'
    /usr/share/foreman/app/services/topbar_sweeper.rb:18:in `block in expire_cache_all_users'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `each'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `expire_cache_all_users'
    /usr/share/foreman/config/initializers/foreman.rb:35:in `block in <top (required)>'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `instance_exec'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `block in make_lambda'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `catch'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `block in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:199:in `block in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `block in invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `each'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:105:in `run_callbacks'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/reloader.rb:88:in `prepare!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `instance_exec'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `block in run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `run'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:61:in `block in run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:60:in `run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:391:in `initialize!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `public_send'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `method_missing'
    /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
    /usr/share/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    /usr/share/gems/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `block in require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:299:in `load_dependency'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `require'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:367:in `require_environment!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
    /usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
    Tasks: TOP => db:abort_if_pending_migrations => db:load_config => environment
    (See full trace by running task with --trace)
  /Stage[main]/Foreman::Database/Foreman::Rake[db:migrate]/Exec[foreman-rake-db:migrate]/returns
    rake aborted!
    Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `new'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `connect_addrinfo'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:193:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each_with_index'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:305:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:385:in `establish_connection'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:117:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:344:in `with_reconnect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:116:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:417:in `ensure_connected'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:269:in `block in process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:356:in `logging'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:268:in `process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:162:in `call'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:564:in `block in del'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `block in synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:563:in `del'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block (2 levels) in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:25:in `with'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:478:in `failsafe'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:417:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/strategy/local_cache.rb:170:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:487:in `block in delete'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `block in instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:205:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:486:in `delete'
    /usr/share/foreman/app/services/topbar_sweeper.rb:18:in `block in expire_cache_all_users'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `each'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `expire_cache_all_users'
    /usr/share/foreman/config/initializers/foreman.rb:35:in `block in <top (required)>'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `instance_exec'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `block in make_lambda'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `catch'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `block in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:199:in `block in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `block in invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `each'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:105:in `run_callbacks'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/reloader.rb:88:in `prepare!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `instance_exec'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `block in run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `run'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:61:in `block in run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:60:in `run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:391:in `initialize!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `public_send'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `method_missing'
    /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
    /usr/share/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    /usr/share/gems/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `block in require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:299:in `load_dependency'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `require'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:367:in `require_environment!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
    /usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
    Tasks: TOP => db:migrate => db:load_config => environment
    (See full trace by running task with --trace)
    change from 'notrun' to ['0'] failed: '/usr/sbin/foreman-rake db:migrate' returned 1 instead of one of [0]
    rake aborted!
    Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2)
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:21:in `initialize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `new'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:151:in `connect_addrinfo'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:193:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `each_with_index'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:191:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/connection/ruby.rb:305:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:385:in `establish_connection'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:117:in `block in connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:344:in `with_reconnect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:116:in `connect'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:417:in `ensure_connected'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:269:in `block in process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:356:in `logging'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:268:in `process'
    /usr/share/gems/gems/redis-4.5.1/lib/redis/client.rb:162:in `call'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:564:in `block in del'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `block in synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:72:in `synchronize'
    /usr/share/gems/gems/redis-4.5.1/lib/redis.rb:563:in `del'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block (2 levels) in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:25:in `with'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:418:in `block in delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:478:in `failsafe'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/redis_cache_store.rb:417:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache/strategy/local_cache.rb:170:in `delete_entry'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:487:in `block in delete'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `block in instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/notifications.rb:205:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:726:in `instrument'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/cache.rb:486:in `delete'
    /usr/share/foreman/app/services/topbar_sweeper.rb:18:in `block in expire_cache_all_users'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `each'
    /usr/share/foreman/app/services/topbar_sweeper.rb:17:in `expire_cache_all_users'
    /usr/share/foreman/config/initializers/foreman.rb:35:in `block in <top (required)>'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `instance_exec'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:427:in `block in make_lambda'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:604:in `block (2 levels) in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `catch'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:603:in `block in default_terminator'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:199:in `block in halting'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `block in invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `each'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:512:in `invoke_before'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/callbacks.rb:105:in `run_callbacks'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/reloader.rb:88:in `prepare!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application/finisher.rb:124:in `block in <module:Finisher>'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `instance_exec'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:32:in `run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `block in run'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:17:in `benchmark'
    /usr/share/foreman/config/initializers/0_print_time_spent.rb:45:in `run'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:61:in `block in run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/initializable.rb:60:in `run_initializers'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:391:in `initialize!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `public_send'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/railtie.rb:207:in `method_missing'
    /usr/share/foreman/config/environment.rb:5:in `<top (required)>'
    /usr/share/gems/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
    /usr/share/gems/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `block in require'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:299:in `load_dependency'
    /usr/share/gems/gems/activesupport-6.1.7.7/lib/active_support/dependencies.rb:332:in `require'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:367:in `require_environment!'
    /usr/share/gems/gems/railties-6.1.7.7/lib/rails/application.rb:533:in `block in run_tasks_blocks'
    /usr/share/gems/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
    Tasks: TOP => db:migrate => db:load_config => environment
    (See full trace by running task with --trace)

1 error was detected during installation.
Please address the errors and re-run the installer to ensure the system is properly configured.
Failing to do so is likely to result in broken functionality.

The full log is at /var/log/foreman-installer/katello.log
[root@foreman ~]#

No configuration files have changed since our original install on 3.5, the journey up to 3.8 has been perfectly fine, and now 3.9 is producing this error for db:migrate which I don’t understand.

Any help would be appreciated.
Thanks.

Found the issue, the clue was the line Errno::EAFNOSUPPORT: Address family not supported by protocol - socket(2) which is a linux networking error.

Something has changed in Foreman to require IPv6 being enabled, however we disable IPv6 in the kernel using grubby. This is the workaround I used

grubby --info ALL | grep "ipv6.disable" #This will show if IPv6 is disabled in the kernel
grubby --update-kernel=ALL --remove-args="ipv6.disable=1" #Enable IPv6
reboot
foreman-installer --scenario katello
grubby --update-kernel=ALL --args="ipv6.disable=1" #Disable it again
reboot
grubby --info ALL | grep "ipv6.disable" #Verify it is disabled.