fix(logging): Fix deadlock in log batcher #5684
1 issue
code-review: Found 1 issue (1 high)
High
Re-entry guard flag not reset on early return, causing spans to be silently dropped - `sentry_sdk/_span_batcher.py:65-66`
When _ensure_thread() returns False or _flusher is None, the function returns at line 66 without entering the try/finally block. This leaves self._active.flag set to True, causing all subsequent calls to add() on the same thread to be silently dropped. Compare with the parent Batcher.add() in _batcher.py where the _ensure_thread() check is inside the try block to ensure the flag is always reset.
Duration: 57.8s · Tokens: 148.0k in / 3.7k out · Cost: $0.23 (+extraction: $0.01, +fix_gate: $0.00)
Annotations
Check failure on line 66 in sentry_sdk/_span_batcher.py
sentry-warden / warden: code-review
Re-entry guard flag not reset on early return, causing spans to be silently dropped
When `_ensure_thread()` returns `False` or `_flusher is None`, the function returns at line 66 without entering the try/finally block. This leaves `self._active.flag` set to `True`, causing all subsequent calls to `add()` on the same thread to be silently dropped. Compare with the parent `Batcher.add()` in `_batcher.py` where the `_ensure_thread()` check is inside the try block to ensure the flag is always reset.