php / php/php-src

PHP 8.2 FPM Leaks processes on pcntl_fork

Aperta
#12,155 13 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Extension: pcntl Feature Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il riproduttore index.php di Drupal 10 fornito, in particolare con la chiamata a pcntl_fork() e il comportamento dei processi PHP-FPM. Riproducilo con PHP 8.2.10 su Ubuntu 16.04 e confrontalo con PHP 7.4. È fatto quando i processi forkati vengono ripuliti dopo la sospensione, invece di scollegarsi e rimanere sotto il processo master FPM.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php
Ambito
backend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.