php / php/php-src

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

Offen
#22,981 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Extension: pdo_mysql Status: Needs Triage
Vorherrschende Sprache
C
Sterne
40.4k
Forks
8.1k
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
96

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Der gemeldete Einstiegspunkt ist PDO->__construct() beim Verbinden mit MySQL über einen Unix-Socket; das relevante Subsystem ist die mysqlnd-Erweiterung. Beginne damit, die Verbindungssequenz mit hoher Häufigkeit unter PHP 8.5.9 und Debian 12 zu reproduzieren, und untersuche anschließend, wie Socket-Wiederholungsversuche behandelt werden; abgeschlossen ist die Aufgabe, wenn die Sequenz nicht mehr SQLSTATE[HY000] [2002] Resource temporarily unavailable zurückgibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
mysql, php
Bereich
databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.