-
Notifications
You must be signed in to change notification settings - Fork 590
Closed
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.54.0
Steps to Reproduce
- Initialize sentry-sdk with
enable_logs=True - Enable warning capture:
logging.captureWarnings(True) - Set
warnings.filterwarnings("always", category=ResourceWarning) - Pre-fill the log batcher with ~2000 log messages
- Trigger a flush on a background thread
- During flush, cause a ResourceWarning to be emitted (e.g. via GC callback)
- The warning is routed through stdlib logging → Sentry logging integration → LogBatcher.add()
- LogBatcher.add() attempts to acquire _log_batcher._lock
- flush() already holds _lock on the same thread → self-deadlock
- Attempt to log from another thread — it will hang indefinitely
Repro script is attached (reproduces reliably on Python 3.11, sentry-sdk 2.54.0).
Expected Result
Flushing logs should not deadlock when a warning is emitted on the flush thread.
Either:
_log_batcher._lockshould be athreading.RLock(reentrant lock) to allow
re-entry on the same thread, or- The logging integration should not attempt to add to the batcher while a flush
is already in progress on the same thread.
Currently, the non-reentrant lock causes the flush thread to self-deadlock,
which then blocks all other threads that attempt to log — freezing the entire application.
Actual Result
Application freezes indefinitely; flush thread self-deadlocks, blocking all subsequent logging across all threads.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Projects
Status
No status