Skip to content

Temp [ improve worker observability ]#109

Open
bKP451 wants to merge 2 commits into
Betterment:mainfrom
bKP451:bikash/improve-worker-observability
Open

Temp [ improve worker observability ]#109
bKP451 wants to merge 2 commits into
Betterment:mainfrom
bKP451:bikash/improve-worker-observability

Conversation

@bKP451
Copy link
Copy Markdown

@bKP451 bKP451 commented May 28, 2026

don’t give crayons to more kids than the box has.

Summary

Improve Delayed::Worker#work_off observability and failure handling around worker thread setup.

What Changed

  • Add debug-level logs around job reservation, batch dispatch, thread waiting, and batch completion inside work_off
  • Include job name and id when a queued job is handed off for thread execution
  • Include job context in the thread crash log by using job_say
  • Distinguish thread crashes that happen before perform from those that happen after it starts
  • Route pre-perform thread crashes through normal job error handling instead of only logging them
  • Cap the worker thread pool size based on the Active Record connection pool so a batch does not fan out beyond available connections

Why

The worker previously had two observability gaps:

  • work_off did not log enough detail to show where a batch was in the reserve and dispatch flow
  • thread setup failures could be logged without enough job context, and pre-perform crashes were not handled through the normal job failure path

This change makes worker execution easier to trace and improves behavior when a thread fails before the job body starts running.

Behavior

  • Adds new debug-level logs for the work_off loop
  • Preserves existing handling for crashes that happen after perform has started
  • Changes pre-perform thread crashes so they are treated like job failures instead of being logged and dropped
  • Limits thread fan-out per batch to reduce the chance of exhausting the Active Record connection pool

@bKP451 bKP451 force-pushed the bikash/improve-worker-observability branch from 6b615b8 to 0101b39 Compare May 28, 2026 04:36
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.

1 participant