Keep disk retries with the process that queued them

Merged
SK
23d ago
+132-3

DiskRetryer keeps failed exports in a temp directory and cleanup_disk_retryers deletes that directory at exit. A forked child inherits the retryer, so a worker that exits normally deletes the directory its parent is still retrying from.

You hit this with a prefork server if the master had a failed export before forking, e.g. gunicorn with preload_app when the backend isn't reachable at boot. Recycling a worker loses what the master had queued, and since the directory is only created once, the master can't queue anything in later outages either.

Each retryer now records the pid that created it. close does nothing in any other process (so the child never touches the inherited lock or directory), and OTLPExporterHttpSession.retryer starts a new retryer in the child, so each process only retries the exports it failed to send.

test_forked_child_leaves_disk_retries_to_the_parent uses a real fork and fails on main because the parent's directory is gone after the child's exit cleanup. tests/exporters/test_otlp_session.py passes with the change. In a full local run on macOS and Python 3.13 the only failures were ones that also happen on main: the Docker-based tests, plus intermittent socket ResourceWarnings.