Skip to content

[BUG] Intermittent PDO connection failure (EINPROGRESS) with dd-trace-php 1.17.1 on Apache prefork + PHP 7.2 #3785

@torder-devops-hyunjoon-song

Description

Bug report

Bug description

After upgrading dd-trace-php from 1.15.0 to 1.17.1, we are experiencing intermittent PDO::__construct() failures with SQLSTATE[HY000] [2002] Operation now in progress (EINPROGRESS) on Apache prefork with PHP 7.2.

The issue occurs on approximately 3% of requests and has been consistently reproducible since the upgrade. Downgrading to 1.15.0 immediately resolves the issue.

Environment

  • PHP: 7.2.34 (ppa:ondrej/php, sury.org)
  • SAPI: Apache 2.4.52 with mpm_prefork
  • OS: Ubuntu 22.04 (container)
  • MySQL driver: mysqlnd 5.0.12-dev
  • Database: Amazon RDS MySQL 8.0.43 (read replica endpoint)
  • Infrastructure: Kubernetes (EKS), 6 pods across 3 nodes
  • dd-trace-php: 1.17.1 (issue present), 1.15.0 (issue absent)

Error

[Tue Apr 14 00:14:06.974280 2026] [php7:error] [pid 571] [client 172.30.21.97:18982] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [2002] Operation now in progress in /var/www/html/application/libs/controller.php:42\nStack trace:\n#0 /var/www/html/application/libs/controller.php(42): PDO->__construct('mysql:host=...', '...', '...', Array)\n#1 /var/www/html/application/libs/controller.php(36): Controller->dbConnect()\n#2 /var/www/html/application/libs/application.php(28): Controller->__construct()\n#3 /var/www/html/index.php(21): Application->__construct()\n#4 {main}\n  thrown in /var/www/html/application/libs/controller.php on line 42

Steps to reproduce

  1. Deploy Apache prefork + PHP 7.2 with dd-trace-php 1.17.1
  2. Configure PDO MySQL connection to a remote RDS instance
  3. Send sustained traffic (~15 req/s per pod)
  4. Observe intermittent EINPROGRESS errors on PDO::__construct()

Key observations

  • CLI PDO connection test: 100+ attempts, 0 failures (even with ddtrace loaded)
  • Apache requests: ~2.2% failure rate (61 failures / ~2800 requests over 2.5 hours)
  • All 6 pods across 3 different nodes are affected
  • Downgrading to dd-trace-php 1.15.0 immediately resolves the issue
  • DB metrics are completely normal; no connection pool exhaustion
  • Node-level network metrics (conntrack, TCP retransmits, ARP) are all normal
  • At the moment of error, TIME_WAIT sockets were elevated (~485) but well within ephemeral port range limits

Suspected cause

dd-trace-php 1.17 introduced changes to sidecar communication:

We suspect the sidecar's signal handling (e.g., SIGVTALRM) is interrupting the connect() syscall during PDO's non-blocking connection attempt via mysqlnd. When the signal interrupts connect() mid-handshake, it returns EINPROGRESS, and mysqlnd does not retry, resulting in a PDOException.

This would explain why:

  • CLI tests pass (short-lived process, fewer sidecar signals)
  • Apache prefork fails intermittently (long-lived processes with continuous sidecar activity)

Workaround

Pin dd-trace-php to version 1.15.0:

RUN curl -LO https://github.com/DataDog/dd-trace-php/releases/download/1.15.0/datadog-setup.php

PHP version

7.2.34

Tracer or profiler version

1.17.1

Installed extensions

[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
ddappsec
ddtrace
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
ddappsec
ddtrace

Output of phpinfo()

No response

Upgrading from

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions