Fix ETSCronFlusher crash on flush timeout - #281
Open
btribouillet wants to merge 3 commits into
Open
Conversation
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
…gger.error for Sentry capture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Task.await/2withTask.yield/2+Task.shutdown/1inETSCronFlusher.handle_info/2so the GenServer logs a warning instead of crashing when an ETS flush exceeds the timeout.ets_flush_timeoutconfig option (default:10_000ms), following the same pattern asets_flush_interval.Fixes #279
Problem
Task.await/2raises an exit on timeout, which terminates theETSCronFlusherGenServer. Under load (or whenget_metrics/1is 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.exTask.await→Task.yield+Task.shutdown(graceful timeout handling)ets_flush_timeout) instead of a hardcoded module attributelib/prom_ex/config.exets_flush_timeoutoption (default:10_000ms) added to Config structlib/prom_ex.exets_flush_timeoutis threaded through from config to ETSCronFlusher child specUsage