Skip to content

Use async_server as default execution mode in Development environment #139

Closed
@multiplegeorges

Description

Hi @bensheldon

In development mode, good_job runs :inline, but seems to ignore the scheduled_at attribute and executes the job immediately. This makes sense, but was somewhat unexpected and I had to refer to the docs to figure it out.

I expected it to run more akin to an async, in-process job, but still respect the scheduled_at.

What happened

I had called MyJob.set(wait: 5.seconds).perform_later and the job executed immediately.

This created a job record in a seemingly impossible (or at least undesirable) state:

pry(main)> GoodJob::Job.all
  GoodJob::Job Load (0.6ms)  SELECT "good_jobs".* FROM "good_jobs"
=> [#<GoodJob::Job:0x00007fda65bd1270
  id: "53ff8466-0956-4023-9ae2-dbd80f8df3f6",
  queue_name: "default",
  priority: 0,
  serialized_params:
   {"job_id"=>"20cebbf0-b2c3-4f48-a8d3-00cb643afe06",
    "locale"=>"en",
    "priority"=>nil,
    "timezone"=>"UTC",
    "arguments"=>[],
    "job_class"=>"MyJob",
    "executions"=>0,
    "queue_name"=>"default",
    "enqueued_at"=>"2020-09-16T21:47:52Z",
    "provider_job_id"=>nil,
    "exception_executions"=>{}},
  scheduled_at: Wed, 16 Sep 2020 21:47:57 UTC +00:00,
  performed_at: Wed, 16 Sep 2020 21:47:52 UTC +00:00,
  finished_at: Wed, 16 Sep 2020 21:47:53 UTC +00:00,
  error: nil,
  created_at: Wed, 16 Sep 2020 21:47:52 UTC +00:00,
  updated_at: Wed, 16 Sep 2020 21:47:53 UTC +00:00>]

This job has performed_at set earlier than scheduled_at.

What I expected

That the job would enqueue, wait 5 seconds, and execute async, but in-process, much like the default Rails async job behaviour.

This matches what will happen in production more closely and avoids records in impossible states.

Thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions