Skip to content

[BUG] Odd behavior in forked CLI processes #1158

Description

@mucha55

Bug description

Hello, we are experiencing some odd behavior in CLI processes that use pcntl_fork() with the ddtrace extension installed. This is in an environment where tracing is enabled for HTTP (PHP-FPM), but disabled for CLI (due to an issue submitted by my colleague). Top-level processes behave well, but any forked processes take a consistent 5 seconds to exit after executing their code (barebones example found here). Tweaking the configuration (with full re-deployments in between) or manually flushing/finishing/closing spans and scopes has no effect on that delay; the only way to get forked processes to behave is by fully disabling (ddtrace.disable=On) or uninstalling the extension (dpkg -r datadog-php-tracer). Is there any way for us to remove this exit delay from forked CLI processes without affecting HTTP tracing?

PHP version

PHP 7.4.11 (cli) (built: Oct  1 2020 19:44:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies
    with ddtrace v0.51.0, Copyright Datadog, by Datadog

Installed extensions

[PHP Modules]
bcmath
Core
ctype
curl
date
ddtrace
dom
fileinfo
filter
ftp
gd
hash
iconv
imap
json
libxml
mbstring
memcached
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
zookeeper

[Zend Modules]
Zend OPcache
ddtrace

OS info

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster

Diagnostics and configuration

Output of phpinfo() (ddtrace >= 0.47.0)

ddtrace


Datadog PHP tracer extension
For help, check out the documentation at https://docs.datadoghq.com/tracing/languages/php/
(c) Datadog 2020

Datadog tracing support => enabled
Version => 0.51.0
DATADOG TRACER CONFIGURATION => {"date":"2021-02-22T20:27:03Z","os_name":"Linux datadog-example 5.4.0-1029-aws #30~18.04.1-Ubuntu SMP Tue Oct 20 11:09:25 UTC 2020 x86_64","os_version":"5.4.0-1029-aws","version":"0.51.0","lang":"php","lang_version":"7.4.2","env":"prod","enabled":true,"service":"datadog-example","enabled_cli":false,"agent_url":"http://10.128.1.236:8126","debug":false,"analytics_enabled":false,"sample_rate":1.000000,"sampling_rules":null,"tags":null,"service_mapping":null,"distributed_tracing_enabled":true,"priority_sampling_enabled":true,"dd_version":null,"architecture":"x86_64","sapi":"cli","ddtrace.request_init_hook":"/opt/datadog-php/dd-trace-sources/bridge/dd_wrap_autoloader.php","open_basedir_configured":false,"uri_fragment_regex":null,"uri_mapping_incoming":null,"uri_mapping_outgoing":null,"auto_flush_enabled":false,"generate_root_span":true,"http_client_split_by_domain":false,"measure_compile_time":true,"report_hostname_on_root_span":false,"traced_internal_functions":null,"auto_prepend_file_configured":false,"integrations_disabled":null,"enabled_from_env":true,"opcache.file_cache":null}

                               Diagnostics
Diagnostic checks => passed

Directive => Local Value => Master Value
ddtrace.disable => Off => Off
ddtrace.request_init_hook => /opt/datadog-php/dd-trace-sources/bridge/dd_wrap_autoloader.php => /opt/datadog-php/dd-trace-sources/bridge/dd_wrap_autoloader.php

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions