Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor inline adapter to enable deferred execution after enqueue to allow batch-callbacks to use transaction-based advisory lock #1433

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

bensheldon
Copy link
Owner

I'm not quite sure whether the "juice is worth the squeeze" here, but it feels like the more correct thing to do.

Eventually, GoodJob will move to using a combination of row-level locking (to execute jobs) and transaction-level advisory locks (for control/synchronization). To use transaction-level advisory locks (instead of the current connection-based advisory locks), the locks have to be wrapped in a transaction. I would prefer jobs not execute within a transaction, but this presents a problem for Inline Execution mode in places where it's necessary to take a lock, and enqueue a job. Though this is (right now, maybe always) just a problem for the batch-callback job enqueueing. Which means, this is really a bunch of effort solely so that:

  • Batch callbacks can be synchronized with a transaction-based advisory lock
  • ...and when running in inline execution mode,
  • ...the batch-callback job is not executed inline within a transaction.

lib/good_job/adapter.rb Outdated Show resolved Hide resolved
@bensheldon bensheldon force-pushed the defer-inline branch 2 times, most recently from 1aa8e46 to ec1b0f7 Compare July 17, 2024 16:10
@bensheldon bensheldon added the refactor Code changes that do not introduce new features label Jul 31, 2024
@bensheldon bensheldon marked this pull request as ready for review July 31, 2024 00:50
@bensheldon bensheldon force-pushed the defer-inline branch 2 times, most recently from 2d97236 to f63661b Compare July 31, 2024 01:18
… allow batch-callbacks to use transaction-based advisory lock
@bensheldon bensheldon merged commit 02fb0b6 into main Jul 31, 2024
14 checks passed
@bensheldon bensheldon deleted the defer-inline branch July 31, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code changes that do not introduce new features
Projects
Development

Successfully merging this pull request may close these issues.

1 participant