-
Notifications
You must be signed in to change notification settings - Fork 2k
ngx.location.capture and sendfile #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@cmaion Crashing is not acceptable and must be fixed. Will you please provide a minimal and self-contained test case that can reproduce it easily on our side? |
@cmaion And BTW, it's Lua, not LUA. Please see http://www.lua.org/about.html#name |
OK ;) The crashes left the following traces in the logs:
or
I ran gdb on one of the core file I got: it confirmed that it was related to a huge body being sent back from the subrequest (due to a subrequest serving a file with sendfile which got fully buffered within the subrequest):
As you can see, a 2563661604 bytes body as the subrequest response is probably not recommended ;) Are you sure that a minimal test case would be necessary? Thanks, |
Hello, Yes, 2563661604 is too large You can also use lua-resty-http[1] which support streaming way (avoid all 2015-11-17 17:19 GMT+08:00 cmaion [email protected]:
|
Hi @doujiang24, thanks for this clarification. Didn't know about lua-resty-http, looks handy -- I believe that I the Nginx/sendfile code path is more appropriate in my case (I just need Lua to detect & manage the internal redirection), but nice to know! |
@cmaion Yeah, it's pointless to use sendfile with ngx.location.capture since the latter always fully buffer the whole subrequest response body. In addition, if your subrequest's response body is indeed 2GB-ish, then the LuaJIT VM crash is expected due to the (default) GC-managed memory limit of LuaJIT on x86_64. |
Yes, exactly. Crashes "as expected" -- expected, as long as one understand that the response body is fully buffered within the subrequest (and that a sendfile performed from the subrequest naturally happens within the subrequest). Thanks again for your work & support! |
@cmaion Yeah, a note is good. Mind to submit a patch? ;) |
@agentzh sure. Something like that? |
Hi,
Got bitten by workers crashes in LUA due to ngx.location.capture requesting a location that has the ability to sendfile large files.
Found out that if subrequests makes use of the X-Accel-Redirect, the actual file content gets fully loaded within the subrequest, and then sent back to LUA at once, as a single large chunk of memory... and potentially blowing stuff in the LUA VM.
This is actually understandable, but a quick note in the doc might help as it's easy to overlook this!
My fix in my case is to:
Not sure if a better/nicer way exists though!
Cedric
The text was updated successfully, but these errors were encountered: