php / php/php-src

Opcache prevents file from being added to realpath cache?

Abierto
#15,030 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Bug Extension: opcache Status: Needs Triage
Lenguaje dominante
C
Estrellas
40.4k
Forks
8.1k
Merge medio
2 d 13 h
PR fusionados (30 d)
96

Descripción

Description

realpath cache is a per process cache
opcache is a shared cache

opcache is enabled with validation 2 seconds

foo.php contains:

<?php $t = time();

bar.php contains:

$path = '../foo.php';
require_once $path;
echo $t;

var_dump( realpath_cache_get() );

with php-fpm request bar.php multiple times.

when checking realpath_cache_get() we see foo.php is added to the realpath cache
as soon as opcache has cached this require once foo.php, foo.php is removed from realpath cache - for most worker processes.

Questions:

  1. opcache seems to be able to clear the realpath cache for some (?) workers - how is opcache able to do that? or does this happen on every request separately? (how come that foo.php is still in realpath cache for some workers though?)

  2. no matter what (is_file, realpath,...) calls with ../foo.php will never make it populate realpath cache again with this file, once it's in opcache - even when calling clearstatcache before it because the file is potentially deleted beforehand. It always seems to fetch the full path again from disk instead of storing it in realpath?

PHP Version

8.3

Operating System

No response

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Reproduce el comportamiento con foo.php y bar.php bajo php-fpm, usando require_once, realpath_cache_get(), is_file(), realpath() y clearstatcache(), con la validación de opcache habilitada. Compara los resultados entre procesos worker y rastrea la interacción entre opcache y realpath-cache; se considera terminado cuando se expliquen los distintos contenidos de la caché y el fallo al volver a poblar la caché, o se identifique una corrección confirmada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
c, php
Área
backend, performance
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.