Check for deadlocks in telemetry buffers (logs)

Đang mở
#2,898 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@sl0thentr0py đang làm issue này rồi.

Từ ngày 17/3/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Improvement Logs Ruby Task

Context

The Python SDK hit a deadlock in the logs telemetry buffer (Slack thread). The Ruby SDK has a very similar buffer implementation, so we should audit it for the same class of issue.

Problem (from Python)

  • The logs buffer acquires a lock when adding a log and when flushing/clearing the buffer
  • During a flush (lock held), GC ran and emitted a log → the logging integration tried to add it to the buffer → attempted to acquire the already-held lock → deadlock
  • Re-entrant locks didn't help since the GC callback runs on a different thread

What to check in Ruby

  1. Audit the telemetry buffer lock usage — ensure no code path can trigger a re-entrant lock acquisition (e.g. via callbacks, GC, instrumentation side-effects during flush)
  2. Minimize critical sections — the lock should only protect fetch/pop/clear/add operations on the buffer data structure. Envelope construction and other side-effects should happen outside the lock
  3. Consider the .NET approach — their implementation is mostly lock-free (atomic increments/decrements), only locking briefly during flush to extract a copy of the buffer array before releasing

Related

  • Python fix by Ivana: moved side-effect-producing work outside the locked section
  • Java was checked and looks fine (Alexander)
  • .NET uses lock-free atomics, had a separate recursion issue with Debug=true
Ngôn ngữ chính
Ruby
Star
990
Fork
552
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
29

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-ruby

Tất cả issue của getsentry/sentry-ruby

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.