php / php/php-src

set_timeout() fails to terminate execution when IO Latency is high

Aperta
#11,971 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

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

Descrizione

Description

I'm not sure if this is a bug or not and I haven't found the proper channel to ask (shall I raise a discussion in Internals?).

We faced a problem in our production cluster. Our setup is following:

SAPI: fpm
max_execution_time: 28
hard_timeout: 2

When Opcache is reloading, we're having excessive IO pressure, which is expected - PHP starts reading everything from disk, etc... However, scripts started executing for 5+ minutes - that wasn't expected.

Further investigation showed that zend_set_timeout_ex uses setitimer(ITIMER_PROF) by default, which means the time the process spends in IOWait doesn't seem to count.

So, basically, even though our gateway cannot wait for such long - it expects that application will finish earlier, PHP still performs the request. One more backside of such behaviour - the restart of Opcache takes longer - it waits until all the workers finish execution (or become killed by opcache when opcache.force_restart_timeout is reached).

This problem doesn't seem to appear when we use ITIMER_REAL. I can provide how we tested this.

I can see a couple of solutions here:

  • Switch to ITIMER_REAL (it looks like there are some concerns about the Apache module)
  • Choose one over another for some SAPIs when we are sure that there shouldn't be a conflict (e.g. FPM, CLI)
  • Make this behaviour configurable (either at runtime or compile time)
  • Something else?

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 da zend_set_timeout_ex e confronta il comportamento riportato di ITIMER_PROF con ITIMER_REAL in FPM e in presenza di un’elevata latenza I/O. Esamina la problematica relativa al modulo Apache e le alternative proposte; il lavoro è completato quando è stato deciso un comportamento del timer o un approccio di configurazione che impedisca alle richieste di essere eseguite per diversi minuti.

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

Valutazione

Stack tecnologico
c, php
Ambito
operating-systems
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.