Skip to content

Conversation

@philippthun
Copy link
Member

Puma shutdown can race with background metrics TimerTasks, which can lead to non-deterministic termination of threads (including database connections).

Use kill instead of shutdown to dismiss already enqueued tasks while still allowing in-progress tasks to complete. Then call wait_for_termination with a timeout of 1 second and return true only if all tasks terminated successfully. This enables accurate logging (Successfully stopped periodic updates vs. Failed to stop all periodic update tasks).

Instead of calling all update_* methods explicitly in the beginning, configure TimerTasks with run_now: true. Also set interval_type: :fixed_rate so execution timing is deterministic and independent of task duration.

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

Puma shutdown can race with background metrics TimerTasks, which can
lead to non-deterministic termination of threads (including database
connections).

Use 'kill' instead of 'shutdown' to dismiss already enqueued tasks while
still allowing in-progress tasks to complete. Then call
'wait_for_termination' with a timeout of 1 second and return 'true' only
if all tasks terminated successfully. This enables accurate logging
(Successfully stopped periodic updates vs. Failed to stop all periodic
update tasks).

Instead of calling all 'update_*' methods explicitly in the beginning,
configure TimerTasks with 'run_now: true'. Also set 'interval_type:
:fixed_rate' so execution timing is deterministic and independent of
task duration.
@philippthun philippthun force-pushed the periodic-updater-improved-setup-and-shutdown branch from 4174f53 to 1a3590f Compare January 8, 2026 12:01
@philippthun philippthun marked this pull request as ready for review January 8, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant