solid_queue icon indicating copy to clipboard operation
solid_queue copied to clipboard

Error: no implicit conversion of ActiveSupport::TimeWithZone

Open hjleochen opened this issue 2 years ago • 1 comments

env: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux] Rails 7.1.2 Mysql 5.7

[ActiveJob] SolidQueue::Job Create (1.7ms) INSERT INTO solid_queue_jobs (queue_name, class_name, arguments, priority, active_job_id, scheduled_at, finished_at, concurrency_key, created_at, updated_at) VALUES ('default', 'FutureInsJob', '{"job_class":"FutureInsJob","job_id":"071e3a57-3b88-4a9e-a363-0f84aef16580","provider_job_id":null,"queue_name":"default","priority":null,"arguments":[],"executions":0,"exception_executions":{},"locale":"en","timezone":"UTC","enqueued_at":"2023-12-22T04:21:08.478Z","scheduled_at":null}', 0, '071e3a57-3b88-4a9e-a363-0f84aef16580', '2023-12-22 04:21:08.478207', NULL, NULL, '2023-12-22 04:21:08.504246', '2023-12-22 04:21:08.504246')

[ActiveJob] SolidQueue::Job Create (1.7ms) INSERT INTO solid_queue_jobs (queue_name, class_name, arguments, priority, active_job_id, scheduled_at, finished_at, concurrency_key, created_at, updated_at) VALUES ('default', 'FutureInsJob', '{"job_class":"FutureInsJob","job_id":"24169f46-9bf2-4d16-91be-ff7ec0b61ad5","provider_job_id":null,"queue_name":"default","priority":null,"arguments":[],"executions":0,"exception_executions":{},"locale":"zh-CN","timezone":"Beijing","enqueued_at":"2023-12-22T12:22:07.791+08:00","scheduled_at":null}', 0, '24169f46-9bf2-4d16-91be-ff7ec0b61ad5', '2023-12-22 12:22:07.791779', NULL, NULL, '2023-12-22 12:22:07.820188', '2023-12-22 12:22:07.820188')

solid_queue_failed_executions error:

{"exception_class":"TypeError","message":"no implicit conversion of ActiveSupport::TimeWithZone into String","backtrace":["/user-path/.rbenv/versions/3.1.2/lib/ruby/3.1.0/time.rb:624:in `xmlschema'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activejob-7.1.2/lib/active_job/core.rb:163:in `deserialize'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activejob-7.1.2/lib/active_job/core.rb:66:in `deserialize'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activejob-7.1.2/lib/active_job/execution.rb:29:in `block in execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/callbacks.rb:121:in `block in run_callbacks'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activejob-7.1.2/lib/active_job/railtie.rb:67:in `block (4 levels) in \u003cclass:Railtie\u003e'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/reloader.rb:77:in `block in wrap'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/execution_wrapper.rb:88:in `wrap'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/reloader.rb:74:in `wrap'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activejob-7.1.2/lib/active_job/railtie.rb:66:in `block (3 levels) in \u003cclass:Railtie\u003e'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/callbacks.rb:130:in `instance_exec'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/callbacks.rb:130:in `block in run_callbacks'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/callbacks.rb:141:in `run_callbacks'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activejob-7.1.2/lib/active_job/execution.rb:28:in `execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/solid_queue-0.1.1/app/models/solid_queue/claimed_execution.rb:50:in `execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/solid_queue-0.1.1/app/models/solid_queue/claimed_execution.rb:29:in `perform'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/solid_queue-0.1.1/lib/solid_queue/pool.rb:23:in `block (2 levels) in post'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activesupport-7.1.2/lib/active_support/execution_wrapper.rb:92:in `wrap'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/solid_queue-0.1.1/lib/solid_queue/app_executor.rb:7:in `wrap_in_app_executor'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/solid_queue-0.1.1/lib/solid_queue/pool.rb:22:in `block in post'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/ivar.rb:170:in `safe_execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/future.rb:55:in `block in execute'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'","/user-path/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'"]}

activejob-7.1.2/lib/active_job/core.rb deserialize(job_data)

 self.enqueued_at = Time.iso8601(job_data["enqueued_at"]) if job_data["enqueued_at"]                       
{"job_class"=>"TestJob",
 "job_id"=>"06bf063f-2db2-42f5-bcc1-01c6bf22a1f9",
 "provider_job_id"=>nil,
 "queue_name"=>"default",
 "priority"=>nil,
 "arguments"=>[],
 "executions"=>0,
 "exception_executions"=>{},
 "locale"=>"en",
 "timezone"=>"Beijing",
 "enqueued_at"=>Thu, 21 Dec 2023 18:10:02.000000000 CST +08:00,
 "scheduled_at"=>nil}

class name of job_data[:enqueued_at] ActiveSupport::TimeWithZone

hjleochen avatar Dec 21 '23 10:12 hjleochen

Hey @hjleochen, sorry for the delay on this one; I didn't realise it had been reopened. Could you let me know how you're enqueuing FutureInsJob? Is it via FutureInsJob.perorm_later? And could you show how your solid_queue_jobs table looks like? The output from SHOW CREATE TABLE solid_queue_jobs.

I haven't been able to reproduce this setting my local timezone to "Beijing" 😕

rosa avatar Dec 27 '23 21:12 rosa

Thank you for your reply. After reading the code and comparing the tests, I found that the issue was due to our application configuration. We had previously set ActiveSupport.parse_json_times = true in our project, which caused job.arguments[:enqueued_at] to become a time type and led to the task failure.

hjleochen avatar Dec 30 '23 16:12 hjleochen

Ohhhh! Great find! This is very useful to know, thanks a lot for letting me know 😊 Maybe it's useful for someone else running into this.

Going to close this one then, thanks again!

rosa avatar Dec 30 '23 18:12 rosa