Skip to content

Conversation

adamnoto
Copy link
Contributor

Summary

ActiveJob was not serializing and deserializing scheduled_at properly

Other Information

We use ActiveJob with DelayedJob as adapter. And we are scheduling job in advance for monitoring purpose. However, scheduled_at value is always missing once because it's not even serialized, and also not deserialized as well if given. To achieve that, currently we are monkey patching the ActiveJob::Core.

This PR fix the issue.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@pixeltrix
Copy link
Contributor

Hi @saveav - just to confirm the problem your seeing is that you can't access the scheduled_at data when the job is being performed, not that the job isn't being performed. I'm scheduling jobs in the future with a Delayed::Job backend myself and it's working fine.

@adamnoto
Copy link
Contributor Author

@pixeltrix yes, correct. only when it's being performed do we lost access to the scheduled_at value of the job being performed.

@ignatiusreza
Copy link
Contributor

Some clarification is required as to what #scheduled_at actually means.. as user of Delayed::Job, I was expecting that it will mimic Delayed::Job#run_at, which would changed value on failure.. but, some might also thing that it should return the time for when the job is originally set to run at, even after retry on failure..

@pixeltrix
Copy link
Contributor

Hmm, on reflection I'm 👎 on this as scheduled_at is an implementation detail of how enqueue options are converted to queue adapter semantics. As @ignatiusreza points out there is some confusion as to what it means - for example if you use retry_job on a job failure then it will have a new scheduled_at or possibly even none depending on the options passed at the time. For an application to use this in a meaningful way seems fraught with danger and the developer would be better off passing an explicit argument.

@saveav thanks for the PR, sorry that I can't merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants