This comes from More job timeout tweaks by DazWorrall · Pull Request #1042 · Shopify/shipit-engine · GitHub
Where a before_perform
callback for whatever reason (in this case attempting a lock on a mutex) causes a significant delay in the job execution, the probability that the ActiveRecord objects in the job arguments are stale (not up to date with the latest state of the database) becomes very large.
The before_execute
callback executes prior to deserlializing the job’s arguments; if this callback were exposed, use cases like ours could use it for these sort of long waits, guaranteeing fresh database state when #perform
is invoked.
Would the core team accept a PR which exposes #[before/after/around]_execute
callbacks along with a test demonstrating that this is invoked prior to argument deserlialization?