set_timeout() fails to terminate execution when IO Latency is high
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
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?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei zend_set_timeout_ex und vergleiche das gemeldete Verhalten von ITIMER_PROF mit ITIMER_REAL unter FPM und hoher I/O-Latenz. Prüfe die Bedenken bezüglich des Apache-Moduls und die vorgeschlagenen Alternativen; als erledigt gilt die Aufgabe, wenn ein Timerverhalten oder Konfigurationsansatz festgelegt wurde, der verhindert, dass Requests mehrere Minuten lang ausgeführt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, php
- Bereich
- operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100