sidekiq-cron: Broken job arguments after updating to 1.7 version (extra timestamp argument for jobs taking 0 arguments)
After updating to 1.7, we’ve experienced an issue with an extra argument being added for no reason - as far as the config goes, args
is an empty array, date_as_argument
is set to false. I suspect it’s related to https://github.com/ondrejbartas/sidekiq-cron/pull/329 but haven’t managed yet to identify the exact cause behinf it, especially that enqueue_args
method returns an empty array for affected jobs.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 20
- Comments: 23 (10 by maintainers)
I can second this issue as well. Now we’re getting the following error when using it:
And taking one of the errors of ours as example, the array below represents the arguments it received while it wasn’t expecting any arguments:
@Azdaroth @leandro if like us you upgrade to 1.7.0 before realising the new argument, then I would recommend you to delete all your existing cron jobs and restart sidekiq. This will then recreate the job now setting correctly the
date_as_argument
as false.I think, if like us you deployed the code before setting the
date_as_argument:
tofalse
then the jobs were now set in stone with this a lingering argument.Hello.
I also faced this problem and found the possible cause.
Verification environment
After some trial and error, I found that this problem is caused by the following behavior
It seems that
args["date_as_argument"]
becomes"0"
and is evaluated as true at the following location at sidekiq-cron 1.6.0https://github.com/sidekiq-cron/sidekiq-cron/blob/v1.6.0/lib/sidekiq/cron/job.rb#L282
I’ll try to submit a modified PR.
Ok I can confirm that, once updated to
1.7.0
even if you revert back to1.6.0
the jobs will still send the extra param.To fix this, we’ve deleted the old jobs, and restarted Sidekiq that then re created the new jobs with the
1.6.0
gem loaded.FYI: I have already applied the changes to https://github.com/sidekiq-cron/sidekiq-cron/issues/350#issuecomment-1412892389 in my development environment and deployed multiple times, and have confirmed that the errors that used to appear no longer occur!
Hello everybody 👋🏼
Thanks to @mkusaka (#392) we have now a potential fix!
Please, if you can test this branch in your app and report back, that would be really helpful to release a new version:
It wasn’t quite clear from the above comments but from what I can tell, 1.7.0 ignores date_as_argument in your config and sends the additional date parameter to the perform method anyway.
After downgrading to 1.6.0, the
@date_as_argument=false
had disappeared from my jobs, but the argument was then defined explicitly:@args=[1660264240.1838207]
.As @nicalpi suggested, destroying and recreating my jobs cleared this arg. This is the command I used:
Once this was done, I checked my jobs and I see the argument is gone:
@args=[]
.Note that if you have retries set to true, then you may have a lot of retries still scheduled and you will still see errors coming through. In my case I had days worth of retries which I had to go and kill off. I need to review whether I should really have any of my tasks set to retry: true, but that is nothing to do with this issue.
I’ve downgraded back to 1.4.0 for now as I don’t want to take any chances when I push this into production.