sidekiq-scheduler / sidekiq-scheduler

Lightweight job scheduler extension for Sidekiq

Home Page:https://sidekiq-scheduler.github.io/sidekiq-scheduler/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sidekiq 7.0 support?

aglushkov opened this issue · comments

I have this error when after upgrading sidekiq to 7.0

no implicit conversion of Sidekiq::Config into Hash

Backtrace

2022-10-14T10:04:34.670Z pid=2228626 tid=1byma INFO: Sidekiq 7.0.0.beta1 connecting to Redis with options {:host=>"localhost", :db=>"0", :size=>1, :pool_name=>"default", :url=>nil}
2022-10-14T10:04:34.673Z pid=2228626 tid=1byma WARN: {"context":"Exception during Sidekiq lifecycle event.","event":"startup"}
2022-10-14T10:04:34.673Z pid=2228626 tid=1byma WARN: TypeError: no implicit conversion of Sidekiq::Config into Hash
2022-10-14T10:04:34.674Z pid=2228626 tid=1byma WARN: lib/ruby/gems/3.1.0/gems/sidekiq-scheduler-4.0.3/lib/sidekiq-scheduler/manager.rb:40:in `merge'
lib/ruby/gems/3.1.0/gems/sidekiq-scheduler-4.0.3/lib/sidekiq-scheduler/manager.rb:40:in `load_scheduler_options'
lib/ruby/gems/3.1.0/gems/sidekiq-scheduler-4.0.3/lib/sidekiq-scheduler/manager.rb:21:in `initialize'
lib/ruby/gems/3.1.0/gems/sidekiq-scheduler-4.0.3/lib/sidekiq-scheduler.rb:21:in `new'
lib/ruby/gems/3.1.0/gems/sidekiq-scheduler-4.0.3/lib/sidekiq-scheduler.rb:21:in `block (2 levels) in <main>'
lib/ruby/gems/3.1.0/gems/sidekiq-7.0.0.beta1/lib/sidekiq/component.rb:58:in `block in fire_event'
lib/ruby/gems/3.1.0/gems/sidekiq-7.0.0.beta1/lib/sidekiq/component.rb:57:in `each'
lib/ruby/gems/3.1.0/gems/sidekiq-7.0.0.beta1/lib/sidekiq/component.rb:57:in `fire_event'
lib/ruby/gems/3.1.0/gems/sidekiq-7.0.0.beta1/lib/sidekiq/cli.rb:105:in `run'
lib/ruby/gems/3.1.0/gems/sidekiq-7.0.0.beta1/bin/sidekiq:31:in `<top (required)>'
bin/sidekiq:25:in `load'

Yeah, no support yet... We probably will have to make some core changes to support sidekiq 7

That would be highly appreciated now that Sidekiq 7 has officially been released! 🙏🏼

I have a very hacky-but-appears-to-function branch that (with a minimal Rails 7 app + sidekiq 7) appears to run the scheduler as expected (at least for my use cases).

https://github.com/t27duck/sidekiq-scheduler/tree/sidekiq7

Specs are blowing up and not 100% happy with the hack on top of the previous hack I did to work around Sidekiq's internals changes, but this is at least a starting point.

@marcelolx if you want, I can make my branch a WIP/POC PR to get other's eyes and opinions on it.

@t27duck a PR is more than welcome, we can iterate on top of it. I'm short on time so any help/progress is appreciated!

Happy to attempt at a PR too if any further bandwidth is needed @t27duck @marcelolx

I went and made a PR based on my branch. Obviously, things are still broken in CI.

Day job is a bit hectic for the start of my week, but later on I should be able to take a stab at making it better.

Probably worth moving discussion into that for PR for now?

Definitely @t27duck, and thanks for coming up with a PR!

Thank you so much for your work on this!

hey everyone, @t27duck has done an amazing job with the PR and we have already merged it. Although, we won't cut a release yet because we're working on a refactor to make some things simpler and less painful to deal with (for supporting different Sidekiq versions), if you'll want to keep an eye on it or have suggestions, feel free to comment on #412

While no release is made, you can point sidekiq-scheduler in your Gemfile to the following ⬇️ I recommend pointing to that exact commit because if #412 gets merged, there may be some breaking changes that will make your scheduler stop working.

gem "sidekiq-scheduler", github: "sidekiq-scheduler/sidekiq-scheduler", branch: "master", ref: "76573dbc46c73afa213331049cfc5657582dc376"

Hello everyone, we have released a beta version of sidekiq-scheduler with support for Sidekiq 7 https://github.com/sidekiq-scheduler/sidekiq-scheduler/releases/tag/v5.0.0.beta1

May be a good idea to keep this open until v5 final of the gem goes out

Just deployed beta1 + sidekiq 7.0.2 on a side production app I have. No issues so far as far as I can see. Things are being scheduled as expected at the right time.

May be a good idea to keep this open until v5 final of the gem goes out

Sounds good to me @t27duck!

I'm unable to boot my app using the beta1 release. I get this error:

/usr/local/bundle/gems/sidekiq-scheduler-5.0.0.beta1/lib/sidekiq-scheduler/manager.rb:1:in `require': cannot load such file -- redis (LoadError)
        from /usr/local/bundle/gems/sidekiq-scheduler-5.0.0.beta1/lib/sidekiq-scheduler/manager.rb:1:in `<top (required)>'
        from /usr/local/bundle/gems/sidekiq-scheduler-5.0.0.beta1/lib/sidekiq-scheduler.rb:6:in `require_relative'
        from /usr/local/bundle/gems/sidekiq-scheduler-5.0.0.beta1/lib/sidekiq-scheduler.rb:6:in `<top (required)>'

True enough, it uses require "redis" at the top of that file. Is there an undocumented dependency somewhere?

Gemfile.lock

    sidekiq (7.0.2)
      concurrent-ruby (< 2)
      connection_pool (>= 2.3.0)
      rack (>= 2.2.4)
      redis-client (>= 0.11.0)
    sidekiq-scheduler (5.0.0.beta1)
      rufus-scheduler (~> 3.2)
      sidekiq (>= 4, < 8)
      tilt (>= 1.4.0)

[EDIT:]

I added an empty lib/redis.rb file and the following patch to my config/boot.rb file in Rails:

 ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
 
+$LOAD_PATH << File.expand_path("../lib", __dir__)
+require "redis"
+
 require "bundler/setup" # Set up gems listed in the Gemfile.

Now the app boots and schedule seem to be working correctly.
Maybe this confirms that the dependency isn't used… 🤷

@Mange Does #416 work for you?

It does look like this was a hold over from an older version of the gem + when sidekiq explicitly only worked with the redis gem.

@Mange can you test with v5.0.0.beta2 release? It contains the changes of #416 that @t27duck mentioned

Yes, I can confirm that beta2 worked out of the box without hacks! Thank you!

perfect, thanks for the feedback @Mange!

@t27duck Let's wait another week, then I think we're good to go with a final v5 release.

I found this issue looking up the original error message above (no implicit conversion of Sidekiq::Config into Hash...). I am now running 5.0.0.beta2, and it is working perfectly.

commented

5.0.0.beta2 working fine here too. 👍🏻

Thanks for the updates, I'll push the final release by the end of the week!

I tried 5.0.0.beta2 and I'm getting:

Schedule empty! Set Sidekiq.schedule

I put a breakpoint here and sidekiq_config appears to be the default schedule as if it's never reading config/sidekiq.yml.

I'm using Sidekiq.configure_embed to run sidekiq.

I'm using Sidekiq.configure_embed to run sidekiq.

I added the following to my config block, and it's working:

sidekiq_config = YAML.load_file('config/sidekiq.yml')
config.merge! sidekiq_config 

I guess sidekiq 7 doesn't load config/sidekiq.yml when running embedded.

Doesn't this look more a problem with Sidekiq? If you set a configuration for sidekiq in the sidekiq.yml file, isn't that config being applied to sidekiq when it runs in embed mode? @timscott If you could come up with a sample app, or at least a sample of your sidekiq config file, so I can simulate it here, I would appreciate it

Hello everyone, sidekiq-scheduler v5 has been released https://github.com/sidekiq-scheduler/sidekiq-scheduler/releases/tag/v5.0.0, thanks to everyone involved, we really appreciate it!

@timscott I created a new issue for your problem #419, as soon as I have some time I'll investigate more and come up with a fix, thanks for reporting it.