Re: [THANKS] Re: Deadlock lua when calling register_task inside action function
On Mon, Jan 07, 2019 at 10:46:08AM +0100, Thierry Fournier wrote: > great ! > > Willy, could you apply the attached patch ? applied, thanks! Willy
[THANKS] Re: Deadlock lua when calling register_task inside action function
great ! Willy, could you apply the attached patch ? thanks Thierry 0001-BUG-MEDIUM-dead-lock-when-Lua-tasks-are-trigerred.patch Description: Binary data > On 6 Jan 2019, at 19:11, Thierry Fournier > wrote: > > Hi, > > Thanks for the bug report. > Your "uneducated guess" was right. > > Could you test the patch in attachment ? > > Thanks > Thierry > <0001-BUG-MEDIUM-dead-lock-when-Lua-tasks-are-trigerred.patch> > >> On 2 Jan 2019, at 01:40, Flakebi wrote: >> >> Hi, >> >> I am currently trying to send an http request for some incoming requests to >> a logging server. >> The incoming connection should be handled independent of the logging, so it >> should be possible >> that the incoming connection is already closed, while the logging is still >> in progress. >> >> I use lua to create a new http action. This action then registers a task to >> decouple the logging. >> And the rest happens inside this task. >> >> As far as I understand the lua api documentation, it should be possible to >> call `register_task` [1] >> inside an action. However, HAProxy deadlocks when a request comes in. >> My uneducated guess would be that HAProxy hangs in a spinlock because it >> tries to create a lua context >> while still executing lua. >> >> I tested version 1.8.14 and 1.9.0 and they show the same behaviour. >> The lua version is 5.3.5. >> >> Am I missing something? Should this be possible at all? >> >> gdb tells the following stacktrace. HAProxy never leaves the hlua_ctx_init >> function: >> >> #0 0x08eb8d04fd0f in hlua_ctx_init () >> #1 0x08eb8d0533f0 in ?? () >> #2 0x6de619c40d27 in ?? () from /usr/lib/liblua.so.5.3 >> #3 0x6de619c4db85 in ?? () from /usr/lib/liblua.so.5.3 >> #4 0x6de619c403b3 in ?? () from /usr/lib/liblua.so.5.3 >> #5 0x6de619c410a9 in lua_resume () from /usr/lib/liblua.so.5.3 >> #6 0x08eb8d04cf9a in ?? () >> #7 0x08eb8d05197e in ?? () >> #8 0x08eb8d05d037 in http_req_get_intercept_rule () >> #9 0x08eb8d063f96 in http_process_req_common () >> #10 0x08eb8d08f0f1 in process_stream () >> #11 0x08eb8d156b08 in process_runnable_tasks () >> #12 0x08eb8d0d443b in ?? () >> #13 0x08eb8d02b660 in main () >> >> >> haproxy.cfg: >> global >> lua-load mytest.lua >> >> listen server >> modehttp >> bind :7999 >> http-request lua.test >> server s 127.0.0.1:8081 >> >> >> mytest.lua: >> function test(txn) >> -- This works when commenting out the task creation >> core.register_task(function() >> core.Warning("Aha") >> end) >> end >> >> core.register_action("test", { "http-req" }, test, 0) >> >> >> >> Cheers, >> Flakebi >> >> [1] >> https://www.arpalert.org/src/haproxy-lua-api/1.8/index.html#core.register_task >
Re: Deadlock lua when calling register_task inside action function
Hi, Thanks for the fast fix, everything works fine now! Cheers, Flakebi On Sun, 6 Jan 2019 19:11:21 +0100 Thierry Fournier wrote: > Hi, > > Thanks for the bug report. > Your "uneducated guess" was right. > > Could you test the patch in attachment ? > > Thanks > Thierry pgp3vWrqoKOPK.pgp Description: OpenPGP digital signature
Re: Deadlock lua when calling register_task inside action function
Hi, Thanks for the bug report. Your "uneducated guess" was right. Could you test the patch in attachment ? Thanks Thierry 0001-BUG-MEDIUM-dead-lock-when-Lua-tasks-are-trigerred.patch Description: Binary data > On 2 Jan 2019, at 01:40, Flakebi wrote: > > Hi, > > I am currently trying to send an http request for some incoming requests to a > logging server. > The incoming connection should be handled independent of the logging, so it > should be possible > that the incoming connection is already closed, while the logging is still in > progress. > > I use lua to create a new http action. This action then registers a task to > decouple the logging. > And the rest happens inside this task. > > As far as I understand the lua api documentation, it should be possible to > call `register_task` [1] > inside an action. However, HAProxy deadlocks when a request comes in. > My uneducated guess would be that HAProxy hangs in a spinlock because it > tries to create a lua context > while still executing lua. > > I tested version 1.8.14 and 1.9.0 and they show the same behaviour. > The lua version is 5.3.5. > > Am I missing something? Should this be possible at all? > > gdb tells the following stacktrace. HAProxy never leaves the hlua_ctx_init > function: > > #0 0x08eb8d04fd0f in hlua_ctx_init () > #1 0x08eb8d0533f0 in ?? () > #2 0x6de619c40d27 in ?? () from /usr/lib/liblua.so.5.3 > #3 0x6de619c4db85 in ?? () from /usr/lib/liblua.so.5.3 > #4 0x6de619c403b3 in ?? () from /usr/lib/liblua.so.5.3 > #5 0x6de619c410a9 in lua_resume () from /usr/lib/liblua.so.5.3 > #6 0x08eb8d04cf9a in ?? () > #7 0x08eb8d05197e in ?? () > #8 0x08eb8d05d037 in http_req_get_intercept_rule () > #9 0x08eb8d063f96 in http_process_req_common () > #10 0x08eb8d08f0f1 in process_stream () > #11 0x08eb8d156b08 in process_runnable_tasks () > #12 0x08eb8d0d443b in ?? () > #13 0x08eb8d02b660 in main () > > > haproxy.cfg: > global >lua-load mytest.lua > > listen server >modehttp >bind :7999 >http-request lua.test >server s 127.0.0.1:8081 > > > mytest.lua: > function test(txn) >-- This works when commenting out the task creation >core.register_task(function() >core.Warning("Aha") >end) > end > > core.register_action("test", { "http-req" }, test, 0) > > > > Cheers, > Flakebi > > [1] > https://www.arpalert.org/src/haproxy-lua-api/1.8/index.html#core.register_task