openresty / openresty/stream-lua-nginx-module
worker process suffers CPU 100% usage
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 749
- Forks
- 210
- Ø Merge
- 4 Std. 31 Min.
- Gemergte PRs (30 T.)
- 3
Beschreibung
Hello!
The worker process CPU usage could be 100% if we use the following configuration pattern:
stream {
server {
listen 3105 reuseport;
lua_check_client_abort on; # must be enabled
content_by_lua_block {
local sock, err = ngx.req.socket(true)
sock:settimeout(1800 * 1000)
local readline = sock:receiveuntil("\n")
while not ngx.worker.exiting() do
local line, err = readline(1)
ngx.log(ngx.ERR, "line: ", line)
if not line then
if err then
ngx.log(ngx.ERR, err)
break
end
else
ngx.sleep(5000) -- other yieldable API is also applicable.
end
end
}
}
}
Building a connection through nc and sending some characters then closing it, in the meanwhile, observing the CPU usage by top.
$ nc 127.0.0.1 3105
asjdkl
zxckj
^C
Now you can find the CPU usage reaches 100%.
It's irrelevant with the version of ngx_stream_lua, you can reproduce this problem even with the newest OpenResty.
After investigating the internal of stream-lua-nginx-module, I found it was caused by the indefinitely trigger of ngx_stram_lua_check_broken_connection, which doesn't the check ev->pending_eof flag.
BTW, this issue was found by @tianchaijz.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
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 ngx_stram_lua_check_broken_connection und verfolge die Verarbeitung der Worker-Ereignisse, die an der bereitgestellten Stream-Konfiguration beteiligt ist. Reproduziere das Problem mit der nginx-Konfiguration und den nc-Befehlen und überprüfe anschließend, dass das Schließen der Verbindung nicht mehr zu einer CPU-Auslastung des Workers von 100% führt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, nginx
- Bereich
- backend, networking
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100