Dup_value error after upgrading in 3.4.0

Hi,
I have upgraded my Foreman in 3.4.0 on my dev env and I have this 500 error on log :

2022-09-21T17:32:05 [F|app|3ceccf3e]
3ceccf3e | NoMethodError (undefined method dup_value!' for #<Hash:0x0000558d6a6590d0>): 3ceccf3e | 3ceccf3e | lib/foreman/middleware/logging_context_request.rb:11:in call’
2022-09-21T17:32:13 [I|app|58fa312d] Started GET “/users/login” for 10.0.16.100 at 2022-09-21 17:32:13 +0200
2022-09-21T17:32:13 [I|app|58fa312d] Processing by UsersController#login as HTML
2022-09-21T17:32:14 [W|app|58fa312d] undefined method dup_value!' for 0:Integer 2022-09-21T17:32:14 [I|app|58fa312d] Backtrace for 'undefined method dup_value!’ for 0:Integer’ error (NoMethodError): undefined method dup_value!' for 0:Integer 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/cache/strategy/local_cache.rb:68:in write_entry’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/cache/strategy/local_cache.rb:162:in write_entry' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:145:in block (2 levels) in write’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/dalli/client.rb:263:in with' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:83:in with’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:143:in block in write' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:383:in block in instrument_with_log’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:392:in block in instrument' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:205:in instrument’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:391:in instrument' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:383:in instrument_with_log’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:142:in write' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/active_support/cache/dalli_store.rb:116:in fetch’
58fa312d | /usr/share/foreman/app/services/foreman/bruteforce_protection.rb:10:in get_login_failures' 58fa312d | /usr/share/foreman/app/services/foreman/bruteforce_protection.rb:18:in bruteforce_attempt?’
58fa312d | /usr/share/foreman/app/controllers/concerns/foreman/controller/bruteforce_protection.rb:9:in bruteforce_attempt?' 58fa312d | /usr/share/foreman/app/controllers/users_controller.rb:113:in login’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/basic_implicit_render.rb:6:in send_action' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/abstract_controller/base.rb:228:in process_action’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/rendering.rb:30:in process_action' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/abstract_controller/callbacks.rb:42:in block in process_action’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:117:in block in run_callbacks' 58fa312d | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in set_timezone’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in block in run_callbacks' 58fa312d | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in clear_thread’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in block in run_callbacks' 58fa312d | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in set_topbar_sweeper_controller’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in block in run_callbacks' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/audited-4.10.0/lib/audited/sweeper.rb:14:in around’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in block in run_callbacks' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/audited-4.10.0/lib/audited/sweeper.rb:14:in around’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:126:in block in run_callbacks' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:137:in run_callbacks’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/abstract_controller/callbacks.rb:41:in process_action' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/rescue.rb:22:in process_action’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:34:in block in process_action' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in block in instrument’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/notifications/instrumenter.rb:24:in instrument' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/notifications.rb:203:in instrument’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/instrumentation.rb:33:in process_action' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal/params_wrapper.rb:249:in process_action’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activerecord-6.1.6.1/lib/active_record/railties/controller_runtime.rb:27:in process_action' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/abstract_controller/base.rb:165:in process’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionview-6.1.6.1/lib/action_view/rendering.rb:39:in process' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal.rb:190:in dispatch’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_controller/metal.rb:254:in dispatch' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/routing/route_set.rb:50:in dispatch’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/routing/route_set.rb:33:in serve' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/router.rb:50:in block in serve’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/router.rb:32:in each' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/journey/router.rb:32:in serve’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/routing/route_set.rb:842:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/apipie-dsl-2.5.0/lib/apipie_dsl/static_dispatcher.rb:67:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/apipie-rails-0.5.20/lib/apipie/static_dispatcher.rb:66:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/apipie-rails-0.5.20/lib/apipie/extractor/recorder.rb:137:in call’
58fa312d | /usr/share/foreman/lib/foreman/middleware/libvirt_connection_cleaner.rb:9:in call' 58fa312d | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/apipie-rails-0.5.20/lib/apipie/middleware/checksum_in_headers.rb:27:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/tempfile_reaper.rb:15:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/etag.rb:27:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/conditional_get.rb:27:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/head.rb:12:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/http/permissions_policy.rb:22:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/http/content_security_policy.rb:19:in call' 58fa312d | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:266:in context' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/session/abstract/id.rb:260:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/cookies.rb:689:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/callbacks.rb:27:in block in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/callbacks.rb:98:in run_callbacks' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/callbacks.rb:26:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/debug_exceptions.rb:29:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/rack/logger.rb:37:in call_app’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/rack/logger.rb:28:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/quiet_assets.rb:13:in call’
58fa312d | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/remote_ip.rb:81:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/request_id.rb:26:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/method_override.rb:24:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/runtime.rb:22:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/activesupport-6.1.6.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/executor.rb:14:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/static.rb:24:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/sendfile.rb:110:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/ssl.rb:77:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/actionpack-6.1.6.1/lib/action_dispatch/middleware/host_authorization.rb:142:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/secure_headers-6.4.0/lib/secure_headers/middleware.rb:11:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/engine.rb:539:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/railtie.rb:207:in public_send’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/railties-6.1.6.1/lib/rails/railtie.rb:207:in method_missing' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/urlmap.rb:74:in block in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in each' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/rack-2.2.4/lib/rack/urlmap.rb:58:in call’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/puma-5.6.5/lib/puma/configuration.rb:252:in call' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/puma-5.6.5/lib/puma/request.rb:77:in block in handle_request’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/puma-5.6.5/lib/puma/thread_pool.rb:340:in with_force_shutdown' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/puma-5.6.5/lib/puma/request.rb:76:in handle_request’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/puma-5.6.5/lib/puma/server.rb:443:in process_client' 58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/puma-5.6.5/lib/puma/thread_pool.rb:147:in block in spawn_thread’
58fa312d | /usr/share/foreman/vendor/ruby/2.7.0/gems/logging-2.3.1/lib/logging/diagnostic_context.rb:474:in block in create_with_logging_context' 2022-09-21T17:32:14 [I|app|58fa312d] Rendered common/500.html.erb within layouts/application (Duration: 2.4ms | Allocations: 840) 2022-09-21T17:32:14 [I|app|58fa312d] Rendered layouts/base.html.erb (Duration: 3.0ms | Allocations: 2119) 2022-09-21T17:32:14 [I|app|58fa312d] Rendered layout layouts/application.html.erb (Duration: 7.3ms | Allocations: 3863) 2022-09-21T17:32:14 [I|app|58fa312d] Completed 500 Internal Server Error in 19ms (Views: 11.8ms | ActiveRecord: 0.3ms | Allocations: 7579) 2022-09-21T17:32:14 [F|app|58fa312d] 58fa312d | NoMethodError (undefined method dup_value!’ for #Hash:0x0000558d6a345bc8):
58fa312d |
58fa312d | lib/foreman/middleware/logging_context_request.rb:11:in `call’

Do you have any idea about these ?

Thanks.
Florent.

Hi,
I have replaced “dalli_store” by “mem_cache_store” in there files and it fixed the error :

  • vendor/ruby/2.7.0/gems/dalli-2.7.8/lib/dalli/railtie.rb
  • vendor/ruby/2.7.0/gems/foreman_memcache-0.1.1/lib/foreman_memcache.rb

Source : undefined method `dup_value!' with dalli 2.7.11 and rails 6.1 · Issue #771 · petergoldstein/dalli · GitHub

Florent.

Same problem here, ty for the fix it does the trick ! i’ll post an issue on foreman_memcache github.

foreman_memcache is obsolete, you can get the same functionality with Foreman core without any plugins by now.

cc @ekohl who mentioned that to me and had a link to docs that I can’t find right now

Ah, looking at config, we do support caching to Redis, but not Memcache?

Adding support for Memcache is probably not too hard looking at Caching with Rails: An Overview — Ruby on Rails Guides

Exactly. Our installer can set up Redis caching. From looking at the source (not actually running the commands):

foreman-installer --foreman-rails-cache-store type:redis

This will install the foreman-redis package which ensures the right dependencies are installed. By default it’ll use redis://localhost:8479/0 but you can override it. However, I don’t know if our installer knows how to deal with such a complex data structure.

This is configured here:

As you can see, there’s no equivalent for memcache. I guess patches welcome, though for most people Redis should be sufficient. It’s already present in most cases anyway since our tasking system also uses it.

Ok ty i didn’t know foreman memcache is now obsolete, as in 3.4.0 documentation, chapter 5.8 Multiple Foreman Instances still references this:

  1. You can use a central memcached instance instead of each Foreman instance’s local cache. Foreman has a plugin you can use.

I’m in this case, i have a cluster of 2 foreman instances running, so using foreman-installer --foreman-rails-cache-store type:redis will probably not save me in my situation, as it seems to configure a local cache on eahc instance, and not a shared cache for all instances.

Foreman installer does not seem to support this, but maybe i can edit the config file on each foreman instance and specify an external redis server ?

Any ideas about this ?

I know this thread is likely dead, but if someone comes across this via Google search like I did today I want to put in what I ended up doing to fix this issue for me. No clue if what I did was correct or the best way to fix the issue, but it seems to have worked. YMMV

Scenario: foreman 3.3.x to 3.4.1 upgrade on Ubuntu 20.04 focal. I had enabled the foreman memcache plugin in a (much) earlier version; but it wasn’t really being used. I was getting the same error that was mentioned at the start of the thread here.

My steps to fix:

  1. Revert back to 3.3.x snapshot before upgrade.
  2. Run these commands in order:
  • foreman-installer --no-enable-foreman-plugin-memcache
  • apt remove memcached ruby-foreman-memcache -y
  • foreman-rake tmp:cache:clear
  • foreman-rake db:sessions:clear
  • su - postgres -c ‘vacuumdb --full --dbname=foreman’
  1. At this point, I rebooted and made sure that everything was still going working OK (along with taking another snapshot).
  2. Upgraded to 3.4.1 using the instructions at Foreman :: Manual . After doing this, 3.4.1 worked fine.

Hopefully this helps someone else in the future!

I completely forgot about this thread, but since there are updates, here we go.

This was resolved in recommend redis over memcache for central caching · theforeman/theforeman.org@9863f89 · GitHub

I didn’t test this yet, but foreman-installer --foreman-rails-cache-store type:redis --foreman-rails-cache-store urls:redis://redis.example.com/PORT/DB should work.

Doesnt look like this is included anywhere in the interactive installer, latest?

The above command does work, but it will actually create the incorrect redis url, within redis itself. It will set the correct url in the config file, but if you check redis it will show up as redis://redis://example.url.com so you’ll need to go into redis and fix it.