Skip to content

Transactional integrity / Job enqueue deferring out of date? #409

Closed
@bakku

Description

@bakku

Hello!

I wonder whether the transactional integrity documentation / job enqueue deferring is out of date.

The README mentions the following:

Because this can be quite tricky and many people shouldn't need to worry about it, by default Solid Queue is configured in a different database as the main app, job enqueuing is deferred until any ongoing transaction is committed thanks to Active Job's built-in capability to do this.

However, with the default configuration the following code seems to enqueue SomeJob even though the transaction is not successful:

class SomeController < ApplicationController
  # ...

  def create
    SomeModel.transaction do
      SomeModel.create!
      SomeJob.perform_later

      raise ActiveRecord::Rollback
    end

    redirect_to root_path
  end
end

The README then continues to mention the following configuration including a link to the Rails documentation :

config.active_job.enqueue_after_transaction_commit

However, the link does not lead to that configuration setting and it seems like the setting was removed in this PR: rails/rails#53375.

To me it seems the only way to currently defer the enqueuing of a job is to configure it on the job level:

class SomeJob < ApplicationJob
  self.enqueue_after_transaction_commit = true

  def perform
    # ...
  end
end

Am I correct that the docs (and default configuration of solid queue) is out of date?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions