Finished profiled transactions keep their Excimer thread until a GC cycle runs
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
How do you use Sentry?
Sentry SaaS (sentry.io)
SDK version
4.18.0, and also reproduced on 4.37.0 (4.38.0 not tested). PHP 8.3.36, ext-excimer 1.2.6, Linux.
Steps to reproduce
Run with php leak.php <dir with sentry/sentry and guzzlehttp/guzzle installed>:
<?php
require $argv[1].'/vendor/autoload.php';
function thr(){ preg_match('/Threads:\s+(\d+)/', file_get_contents('/proc/self/status'), $m); return (int)$m[1]; }
\Sentry\init(['dsn'=>'https://[email protected]/0','traces_sample_rate'=>1.0,'profiles_sample_rate'=>1.0,'transport'=>null]);
$hub=\Sentry\SentrySdk::getCurrentHub();
for($i=0;$i<50;$i++){ $c=\Sentry\Tracing\TransactionContext::make()->setName('job')->setOp('queue.process'); $t=$hub->startTransaction($c); $hub->setSpan($t); $s=$t->startChild(\Sentry\Tracing\SpanContext::make()->setOp('db')); usleep(2000); $s->finish(); $t->finish(); $hub->setSpan(null); unset($t,$s); }
echo \Composer\InstalledVersions::getPrettyVersion('sentry/sentry')." after50=".thr();
gc_collect_cycles(); echo " after_gc=".thr()."\n";
Expected result
The thread count stays flat once each transaction has finished and been dropped.
Actual result
4.18.0 after50=51 after_gc=1
4.37.0 after50=51 after_gc=1
Each profiled transaction leaves one thread behind. The thread goes away only when PHP's cycle collector runs. A standalone ExcimerProfiler that is started, stopped and unset frees its thread at once, so the extra lifetime looks like it comes from the transaction and its spans referencing each other. Profiler::stop() stops the timer but keeps the ExcimerProfiler, and Transaction::finish() keeps the Profiler.
In a long-running worker (Laravel queue:work with sentry-laravel's queue integration) the automatic collector does not always run often enough. In a container limited to 256 processes and threads, the worker reached the limit, and from then on every ExcimerProfiler::start() failed:
ErrorException: ExcimerProfiler::start(): Error in pthread_create(): Resource temporarily unavailable
Laravel turns that warning into an exception, so every queued job failed until the worker restarted. Over 600 simulated jobs, the collector ran twice in the first 150, then not at all, and the thread count stayed at the limit.
Possible fixes: release the profiler when the transaction finishes (for example via detachProfiler(), after the profile has been read), or break the transaction and span reference cycle.
- Ngôn ngữ chính
- PHP
- Star
- 1.9k
- Fork
- 478
- Merge trung bình
- 14 giờ 54 phút
- Pull request đã merge (30 ngày)
- 111
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của getsentry/sentry-php
-
Bug PHP
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
getsentry/sentry-php#2431 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getsentry/sentry-php#2350 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Improvement PHP
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
getsentry/sentry-php#2243 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Implement Global AttributesCó thể làm lại được @Litarnus đã nhận 54 ngày trước và không có pull request nào đang mở. Đang mởPHP
getsentry/sentry-php#2238 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add span streaming supportCó thể làm lại được @Litarnus đã nhận 57 ngày trước và không có pull request nào đang mở. Đang mởPHP Span First
getsentry/sentry-php#2229 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của getsentry/sentry-php
Issue tương tự
-
Appearance enhancement
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 62/100
novalo-dev/Prestashop-MCP-Server#487 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
sync-en
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Перевод устарел
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
iftechfoundation/ifdb#1555 ·
Maintainer thường phản hồi trong vòng 1 ngày