Skip to content

chore(dispatcher): reuse lifecycle operation for job reads - #145

Merged
nicolasburtey merged 1 commit into
mainfrom
codex/fix-job-dispatcher-connection-reuse
Jul 31, 2026
Merged

chore(dispatcher): reuse lifecycle operation for job reads#145
nicolasburtey merged 1 commit into
mainfrom
codex/fix-job-dispatcher-connection-reuse

Conversation

@Nsandomeno

@Nsandomeno Nsandomeno commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Reuse the database operation already opened for job completion, failure, and rescheduling.
  • Prevent concurrent lifecycle transitions from each holding one pool connection while waiting for a second.
  • Provide the material fix for GaloyMoney/lana-bank#7735.

Changes

  • Load jobs with find_by_id_in_op in the completion path.
  • Load jobs with find_by_id_in_op in the failure path.
  • Load jobs with find_by_id_in_op in the rescheduling path.

No schema, behavior, or test changes are needed for this three-line connection-reuse fix.

Testing

  • Validated from lana-bank with a 10-connection pool: the full core-deposit suite passed 102/102 in 8.76 seconds when using this patched job crate.

Note

Low Risk
Three-line internal refactor with identical transaction boundaries; low risk aside from rare edge cases if find_by_id_in_op semantics differ from find_by_id.

Overview
Job lifecycle paths now load entities on the same DB operation used for execution updates, instead of opening a second read via find_by_id.

In fail_job, complete_job, and reschedule_job, reads switch to find_by_id_in_op so failure, completion, and reschedule work no longer hold one pool connection while waiting on another. This is a connection-reuse fix for pool exhaustion under concurrent transitions (e.g. lana-bank #7735); no intended behavior or schema change.

Reviewed by Cursor Bugbot for commit fbfc7e4. Bugbot is set up for automated code reviews on this repo. Configure here.

Load jobs through the operation already opened for completion, failure, and rescheduling. This prevents concurrent lifecycle transitions from each holding one pool connection while waiting for a second.
@nicolasburtey

Copy link
Copy Markdown
Member

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit fbfc7e4. Configure here.

@nicolasburtey
nicolasburtey marked this pull request as ready for review July 31, 2026 22:12
@nicolasburtey
nicolasburtey merged commit 10e6311 into main Jul 31, 2026
5 checks passed
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.

2 participants