php / php/php-src

PHP 8.2 FPM Leaks processes on pcntl_fork

Offen
#12,155 13 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

Description

OS: xenial
PHP tested: 8.2.7, 8.2.10

The following drupal 10 index.php:

<?php

/**
 * @file
 * The PHP page that serves all page requests on a Drupal installation.
 *
 * All Drupal code is released under the GNU General Public License.
 * See COPYRIGHT.txt and LICENSE.txt files in the "core" directory.
 */

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;

$autoloader = require_once 'autoload.php';

$kernel = new DrupalKernel('prod', $autoloader);

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$pid = pcntl_fork();
    if ( $pid !== 0  ) {
        // we are the parent process
        return;
    }
    sleep(10);

$kernel->terminate($request, $response);

After doing ~5 requests to the site, results in the following sub-processes to the FPM master:

root     15873  0.0  0.8 464188 17200 ?        Ss   13:08   0:00 php-fpm: master process (/var/www/site-fpm/drush12test.prod/php-fpm-8.2.conf)
drush12+ 16518  0.7  1.4 466300 29860 ?        S    13:11   0:00  \_ php-fpm: pool drush12test
drush12+ 16557  0.0  0.6 466300 13068 ?        S    13:11   0:00      \_ php-fpm: pool drush12test
drush12+ 16559  0.0  0.6 466300 12640 ?        S    13:11   0:00      \_ php-fpm: pool drush12test
drush12+ 16561  0.0  0.6 466300 12640 ?        S    13:11   0:00      \_ php-fpm: pool drush12test
drush12+ 16563  0.0  0.6 466300 12640 ?        S    13:11   0:00      \_ php-fpm: pool drush12test

But then after a few seconds, when it should clean them up, they will instead detach and linger around:

root     15873  0.0  0.8 464188 17188 ?        Ss   13:08   0:00 php-fpm: master process (/var/www/site-fpm/drush12test.prod/php-fpm-8.2.conf)
drush12+ 16557  0.0  1.1 464252 23364 ?        S    13:11   0:00 php-fpm: pool drush12test
drush12+ 16559  0.0  1.1 464252 23028 ?        S    13:11   0:00 php-fpm: pool drush12test
drush12+ 16561  0.0  1.1 464252 23028 ?        S    13:11   0:00 php-fpm: pool drush12test
drush12+ 16563  0.0  1.1 466300 23432 ?        S    13:11   0:00 php-fpm: pool drush12test

The same doesn't happen with PHP 7.4. In that case the processes get cleaned up properly.

PHP Version

PHP 8.2.10

Operating System

Ubuntu 16.04

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

Beginne mit dem mitgelieferten Drupal-10-index.php-Reproduzierer, insbesondere mit dem Aufruf von pcntl_fork() und dem Verhalten des PHP-FPM-Prozesses. Reproduziere das Problem mit PHP 8.2.10 auf Ubuntu 16.04 und vergleiche es mit PHP 7.4. Als erledigt gilt die Aufgabe, wenn die geforkten Prozesse nach dem sleep bereinigt werden, anstatt sich abzulösen und unter dem FPM-Master weiterzulaufen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

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