Just as a side note: if you really want performance, then you should
avoid using coroutines as much as possible because the coroutine API
is kinda expensive and cannot be JIT compiled. It is recommended to
use simple stream API as in lua-resty-upload:
https://github.com/agentzh/lua-resty-upload
> However if you have several upstream http requests, sometimes aWhich version of ngx_lua (or ngx_openresty) are you using? Looks like
> coroutine will enter the dead state without having ever run.
you're running into an old bug that was fixed in ngx_lua 0.9.1 (or
ngx_openresty 1.4.3.1):
* bugfix: the bookkeeping state for already-freed user threads might
be incorrectly used by newly-created threads that were completely
different, which could lead to bad results. thanks Sam Lawrence for
the report.
> I'd suspected there was just something silly wrong with my code, but it'sRight, this is impossible.
> definitely weirder than that. The coroutine is created (successfully, I get
> a thread value back), and then on the next line I call coroutine.status(co)
> and it returns "dead", which as I understand should be impossible?
> Any ideas on what I can try to narrow this down further?If you're not using the latest ngx_lua, please consider upgrading first :)
>
-agentzh
--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
It's very likely that ngx_http_lua_get_co_ctx() called by
ngx_http_lua_coroutine_status() (for coroutine.status) got a bad
ngx_http_lua_co_ctx_t pointer. Could you add debugging code to check
if the resulting "coctx" pointer remains the same as the original
"coctx" created by ngx_http_lua_coroutine_create_helper?
>
> Any other ideas? :)
>
It'll be great if you can use valgrind's memcheck and/or clang ASan to
check if there are any memory issues in nginx running your code.
You're recommended to enable the no-pool patch when checking memory
issues. Because you're using the openresty bundle, just rebuild it
with the ./configure option --with-no-pool-patch. But don't enable the
no-pool patch for production use :)
I've just committed a patch to ngx_lua's git master:
https://github.com/chaoslawful/lua-nginx-module/commit/8f4c485
The patch includes the example above as a test case in the test suite.
Will you try out the latest master of ngx_lua on your side?
Thank you for your report and analysis!
> "resty.http", and content_by_lua is as per the example in the gist. A ranJust a quick note: all the things in your valgrind output are false
> this and then a single curl against the server which triggered the error.
> The output is here:
> https://gist.github.com/pintsized/7913674#file-valgrind-output
>
positives. You should have passed the valgrind option
--suppressions=/path/to/luajit-2.0/src/lj.supp
to suppress these :)