great ! 

Willy, could you apply the attached patch ?

thanks
Thierry

Attachment: 0001-BUG-MEDIUM-dead-lock-when-Lua-tasks-are-trigerred.patch
Description: Binary data

> On 6 Jan 2019, at 19:11, Thierry Fournier <thierry.fourn...@arpalert.org> 
> 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 <flak...@t-online.de> 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  0x000008eb8d04fd0f in hlua_ctx_init ()
>> #1  0x000008eb8d0533f0 in ?? ()
>> #2  0x00006de619c40d27 in ?? () from /usr/lib/liblua.so.5.3
>> #3  0x00006de619c4db85 in ?? () from /usr/lib/liblua.so.5.3
>> #4  0x00006de619c403b3 in ?? () from /usr/lib/liblua.so.5.3
>> #5  0x00006de619c410a9 in lua_resume () from /usr/lib/liblua.so.5.3
>> #6  0x000008eb8d04cf9a in ?? ()
>> #7  0x000008eb8d05197e in ?? ()
>> #8  0x000008eb8d05d037 in http_req_get_intercept_rule ()
>> #9  0x000008eb8d063f96 in http_process_req_common ()
>> #10 0x000008eb8d08f0f1 in process_stream ()
>> #11 0x000008eb8d156b08 in process_runnable_tasks ()
>> #12 0x000008eb8d0d443b in ?? ()
>> #13 0x000008eb8d02b660 in main ()
>> 
>> 
>> haproxy.cfg:
>> global
>>   lua-load mytest.lua
>> 
>> listen server
>>   mode    http
>>   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
> 

Reply via email to