Skip to content

docs: say when to wipe PROMETHEUS_MULTIPROC_DIR and what breaks if it's wiped later - #1270

Open
naveensheejachacko wants to merge 1 commit into
prometheus:masterfrom
naveensheejachacko:docs/multiproc-dir-wipe-timing
Open

naveensheejachacko wants to merge 1 commit into
prometheus:masterfrom
naveensheejachacko:docs/multiproc-dir-wipe-timing

Conversation

@naveensheejachacko

Copy link
Copy Markdown

Closes #1123 (docs side; I posted the root cause and a reproduction on the issue).

The multiprocess docs say the directory "must be wiped between process/Gunicorn runs (before startup is recommended)", but they don't say what happens when it's wiped later. In #1123 a threaded Celery worker silently lost its metrics while the prefork workers were fine.

The cause: a metric without labels opens its process's <type>_<pid>.db file when it's defined, usually at import time. If the directory is wiped after that (for example in a Celery worker_init handler), the process keeps writing to the deleted file, and every metric of that type in the process stops being reported, including labelled metrics first used after the wipe. Processes forked after the wipe open new files, so prefork pools and Gunicorn workers are unaffected.

This PR:

  • Says the directory must exist and be wiped before any metric is created, and shows the start-up script way of doing it.
  • Describes the failure mode, so people seeing it in single-process workers (Celery threads/solo pools) can recognise it.

Docs only; no code changes. Recovering automatically would need a stat on every write.

@csmarchbanks

🤖 Generated with Claude Code

…'s wiped later

A metric without labels opens its process's <type>_<pid>.db file when
it is defined. If the multiprocess directory is wiped after that, for
example in a Celery worker_init handler, the process keeps writing to
the deleted file and its metrics of that type stop being reported.
Forked workers are unaffected, which is why prometheus#1123 only showed up in a
threaded Celery worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Naveen Chacko <naveensheejachacko@gmail.com>

This branch has not been deployed

No deployments
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.

Metric without labelnames causes issues in when MULTIPROC is enabled

1 participant