net.box: explicitly forbid synchronous requests in triggers
Net.box triggers (on_connect, on_schema_reload) are executed by the net.box connection worker fiber so a request issued by a trigger callback can't be processed until the trigger returns execution to the net.box fiber. Currently, an attempt to issue a synchronous request from a net.box trigger leads to a silent hang of the connection, which is confusing. Let's instead raise an error until #7291 is implemented. We need to add the check to three places in the code: 1. luaT_netbox_wait_result for future:wait_result() 2. luaT_netbox_iterator_next for future:pairs() 3. conn._request for all synchronous requests. (We can't add the check to luaT_netbox_transport_perform_request, because conn._request may also call conn.wait_state, which would hang if called from on_connect or on_schema_reload trigger.) We also add an assertion to netbox_request_wait to ensure that we never wait for a request completion in the net.box worker fiber. Closes #5358 @TarantoolBot document Title: Synchronous requests are not allowed in net.box triggers An attempt to issue a synchronous request (e.g. `call`) from a net.box trigger (`on_connect`, `on_schema_reload`) now raises an error: "Synchronous requests are not allowed in net.box trigger" (Before https://github.com/tarantool/tarantool/issues/5358 was fixed, it silently hung.) Invoking an asynchronous request (see `is_async` option) is allowed, but the request will not be processed until the trigger returns and an attempt to wait for the request completion with `future:pairs()` or `future:wait_result()` will raise the same error.
Showing
- changelogs/unreleased/gh-5358-net-box-sync-request-in-trigger.md 4 additions, 0 deletions...ogs/unreleased/gh-5358-net-box-sync-request-in-trigger.md
- src/box/lua/net_box.c 16 additions, 0 deletionssrc/box/lua/net_box.c
- src/box/lua/net_box.lua 6 additions, 0 deletionssrc/box/lua/net_box.lua
- test/box-luatest/net_box_test.lua 32 additions, 0 deletionstest/box-luatest/net_box_test.lua
Loading
Please register or sign in to comment