Skip to content

Fix ETSCronFlusher crash on flush timeout - #281

Open
btribouillet wants to merge 3 commits into
akoutmos:masterfrom
Flowganise:master
Open

Fix ETSCronFlusher crash on flush timeout#281
btribouillet wants to merge 3 commits into
akoutmos:masterfrom
Flowganise:master

Conversation

@btribouillet

@btribouillet btribouillet commented Feb 26, 2026

Copy link
Copy Markdown

Summary

  • Replace Task.await/2 with Task.yield/2 + Task.shutdown/1 in ETSCronFlusher.handle_info/2 so the GenServer logs a warning instead of crashing when an ETS flush exceeds the timeout.
  • Make the flush timeout configurable via ets_flush_timeout config option (default: 10_000ms), following the same pattern as ets_flush_interval.

Fixes #279

Problem

Task.await/2 raises an exit on timeout, which terminates the ETSCronFlusher GenServer. Under load (or when get_metrics/1 is slow on shared-cpu machines), this causes a crash loop — we were seeing ~500 crashes per 12 hours in production.

Changes

lib/prom_ex/ets_cron_flusher.ex

  • Task.awaitTask.yield + Task.shutdown (graceful timeout handling)
  • Timeout is now read from GenServer state (ets_flush_timeout) instead of a hardcoded module attribute

lib/prom_ex/config.ex

  • New ets_flush_timeout option (default: 10_000ms) added to Config struct

lib/prom_ex.ex

  • ets_flush_timeout is threaded through from config to ETSCronFlusher child spec

Usage

config :my_app, MyApp.PromEx,
  ets_flush_timeout: 30_000  # 30s, default is 10_000

Replace Task.await with Task.yield + Task.shutdown so the GenServer
logs a warning instead of crashing when ETS flush exceeds the 10s
timeout. Fixes akoutmos#279.
Replace Task.await with Task.yield + Task.shutdown so the GenServer
logs a warning instead of crashing when ETS flush exceeds the timeout.

Also make the flush timeout configurable via `ets_flush_timeout` config
option (default: 10_000ms), following the same pattern as
`ets_flush_interval`.

Fixes akoutmos#279
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.

GenServer Shared.Infrastructure.Telemetry.PromEx.ETSCronFlusher terminating

1 participant