Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails.cache.write fails with Integer not defining .utc #2790

Closed
matthewford opened this issue Nov 20, 2022 · 4 comments
Closed

Rails.cache.write fails with Integer not defining .utc #2790

matthewford opened this issue Nov 20, 2022 · 4 comments
Assignees
Labels

Comments

@matthewford
Copy link

matthewford commented Nov 20, 2022

Hello, running the mastodon spec suite (this branch) using truffle ruby, I noticed that I see an error which isn't present under MRI:

undefined method `utc' for 109378368298110438:Integer

Here is the stack trace

   Failure/Error: Rails.cache.write(item, item)

    NoMethodError:
      undefined method `utc' for 109378368298110438:Integer
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/time_with_zone.rb:514:in `marshal_load'
    # <internal:core> core/marshal.rb:939:in `construct_user_marshal'
    # <internal:core> core/marshal.rb:612:in `construct'
    # <internal:core> core/marshal.rb:206:in `block in set_instance_variables'
    # <internal:core> core/integer.rb:148:in `times'
    # <internal:core> core/marshal.rb:204:in `set_instance_variables'
    # <internal:core> core/marshal.rb:1205:in `construct_object'
    # <internal:core> core/marshal.rb:608:in `construct'
    # <internal:core> core/marshal.rb:775:in `block in construct_hash'
    # <internal:core> core/integer.rb:148:in `times'
    # <internal:core> core/marshal.rb:771:in `construct_hash'
    # <internal:core> core/marshal.rb:602:in `construct'
    # <internal:core> core/marshal.rb:206:in `block in set_instance_variables'
    # <internal:core> core/integer.rb:148:in `times'
    # <internal:core> core/marshal.rb:204:in `set_instance_variables'
    # <internal:core> core/marshal.rb:1205:in `construct_object'
    # <internal:core> core/marshal.rb:608:in `construct'
    # <internal:core> core/marshal.rb:206:in `block in set_instance_variables'
    # <internal:core> core/integer.rb:148:in `times'
    # <internal:core> core/marshal.rb:204:in `set_instance_variables'
    # <internal:core> core/marshal.rb:1205:in `construct_object'
    # <internal:core> core/marshal.rb:608:in `construct'
    # <internal:core> core/marshal.rb:1343:in `load'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/core_ext/marshal.rb:8:in `load'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache.rb:841:in `dup_value!'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache/memory_store.rb:36:in `dump'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache.rb:594:in `serialize_entry'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache/memory_store.rb:159:in `write_entry'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache.rb:476:in `block in write'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache.rb:726:in `block in instrument'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/notifications.rb:205:in `instrument'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache.rb:726:in `instrument'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/cache.rb:474:in `write'
    # ./app/controllers/concerns/cache_concern.rb:46:in `block in cache_collection'
    # <internal:core> core/hash.rb:408:in `block in each_value'
    # <internal:core> core/hash.rb:408:in `each_pair'
    # <internal:core> core/hash.rb:408:in `each_value'
    # ./app/controllers/concerns/cache_concern.rb:45:in `cache_collection'
    # ./app/controllers/api/v1/timelines/home_controller.rb:24:in `cached_home_statuses'
    # ./app/controllers/api/v1/timelines/home_controller.rb:20:in `load_statuses'
    # ./app/controllers/api/v1/timelines/home_controller.rb:9:in `show'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/abstract_controller/base.rb:228:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal/rendering.rb:30:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/i18n-1.12.0/lib/i18n.rb:322:in `with_locale'
    # ./app/controllers/concerns/localized.rb:11:in `set_locale'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/callbacks.rb:137:in `run_callbacks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/abstract_controller/callbacks.rb:41:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal/rescue.rb:22:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/notifications.rb:203:in `block in instrument'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activesupport-6.1.7/lib/active_support/notifications.rb:203:in `instrument'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/activerecord-6.1.7/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/abstract_controller/base.rb:165:in `process'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionview-6.1.7/lib/action_view/rendering.rb:39:in `process'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/metal.rb:190:in `dispatch'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/test_case.rb:580:in `process_controller_response'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/test_case.rb:499:in `process'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/template_assertions.rb:62:in `process'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/devise-4.8.1/lib/devise/test/controller_helpers.rb:35:in `block in process'
    # <internal:core> core/throw_catch.rb:36:in `catch'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/devise-4.8.1/lib/devise/test/controller_helpers.rb:104:in `_catch_warden'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/devise-4.8.1/lib/devise/test/controller_helpers.rb:35:in `process'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/actionpack-6.1.7/lib/action_controller/test_case.rb:398:in `get'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/integration.rb:16:in `get'
    # ./spec/controllers/api/v1/timelines/home_controller_spec.rb:24:in `block (4 levels) in <top (required)>'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:263:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:263:in `block in run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:511:in `block in with_around_and_singleton_context_hooks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:468:in `block in with_around_example_hooks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:486:in `block in run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:626:in `block in run_around_example_hooks_for'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:352:in `call'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-rails-5.1.2/lib/rspec/rails/example/controller_example_group.rb:192:in `block (2 levels) in <module:ControllerExampleGroup>'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:390:in `execute_with'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:352:in `call'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-rails-5.1.2/lib/rspec/rails/adapters.rb:75:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:390:in `execute_with'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:352:in `call'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:457:in `instance_exec'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:390:in `execute_with'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:628:in `block (2 levels) in run_around_example_hooks_for'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:352:in `call'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:627:in `run_around_example_hooks_for'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/hooks.rb:486:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:468:in `with_around_example_hooks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:511:in `with_around_and_singleton_context_hooks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example.rb:259:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:646:in `block in run_examples'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:642:in `map'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:642:in `run_examples'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:607:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `block in run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `map'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `block in run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `map'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/example_group.rb:608:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `block (3 levels) in run_specs'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `map'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:121:in `block (2 levels) in run_specs'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/configuration.rb:2068:in `with_suite_hooks'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:116:in `block in run_specs'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/reporter.rb:74:in `report'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:115:in `run_specs'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:89:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:71:in `run'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/lib/rspec/core/runner.rb:45:in `invoke'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/lib/gems/gems/rspec-core-3.11.0/exe/rspec:4:in `<top (required)>'
    # <internal:core> core/kernel.rb:381:in `load'
    # /Users/matthewford/.asdf/installs/ruby/truffleruby-dev/bin/rspec:25:in `<main>'
@matthewford matthewford changed the title Rails.cache.write fails with Integer not defining .uct Rails.cache.write fails with Integer not defining .utc Nov 20, 2022
@matthewford
Copy link
Author

If you want to run a single spec (due to the spec run time you can replicate with

rspec ./spec/controllers/api/v1/favourites_controller_spec.rb

Looking at the rails code for cache write, this line is suspect:
https://github.com/rails/rails/blob/8015c2c2cf5c8718449677570f372ceb01318a32/activesupport/lib/active_support/cache.rb#L1013

I will see if I can replicate the issue with a smaller test case.

@matthewford
Copy link
Author

matthewford commented Nov 21, 2022

Yeah, the file store or Redis store doesn't have this issue; it's an issue with the memory store.

@eregon
Copy link
Member

eregon commented Nov 21, 2022

Thank you for the report.
@andrykonchin Could you investigate this? I think we should find out what is @value on that line and what's the result of the Marshal dump and load.

utc doesn't seem to be defined on Integer by active_support, so I guess the Marshal dumping or loading of some time-like object (probably TimeWithZone) doesn't work as expected.

@andrykonchin
Copy link
Member

Fixed in 051932d

@andrykonchin andrykonchin added this to the 23.0.0 Release milestone Dec 8, 2022
@eregon eregon added the bug label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants