php / php/php-src

Connecting to PDO / MySQL database over unix-socket throws "a retry" error

未关闭
#22,981 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Bug Extension: pdo_mysql Status: Needs Triage
主要语言
C
星标
40.4k
派生
8.1k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

The following code:

<?php

Resulted in this output:

Error message: SQLSTATE[HY000] [2002] Resource temporarily unavailable

Error stack trace:

#0 /location-to-php.php(43): PDO->__construct()
#xx: our code

But I expected this output instead:

No crash.

This is a bug in mysqlnd in that it returns a "2002" error code (I looked into the code -- it's a "try again" code, that is a look / backoff should be taken). This happens when connecting to MySQL using a unix socket. And it happens when a high-frequency of calls are made in short succession.

Ideally a unix-socket should be opened once per process and all communication should happen on that socket (rather than opening and closing it over and over again). And "retry" "errors" (not an error) should be handled correctly.

I haven't dug into the mysqlnd extension into how to fix this yet. If someone wants to jump on this first, that would be appreciated. Otherwise I'll dig into it next week.

PHP Version
8.5.9
Operating System

Debian 12

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

报告的入口点是通过 Unix 套接字连接 MySQL 时的 PDO->__construct();相关子系统是 mysqlnd 扩展。首先在 PHP 8.5.9 和 Debian 12 上重现高频连接序列,然后检查套接字重试的处理方式;当该序列不再返回 SQLSTATE[HY000] [2002] Resource temporarily unavailable 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
mysql, php
领域
databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。