[Tarantool-patches] [PATCH 02/20] net.box: wake up wait_result callers when request is discarded

Vladimir Davydov vdavydov at tarantool.org
Fri Jul 23 14:07:12 MSK 2021


request.discard() doesn't wake up fibers blocked in
request.wait_result() as a result they hang until timeout.
Fix this and add a test.
---
 src/box/lua/net_box.lua                   |  1 +
 test/box/net.box_discard_gh-3107.result   | 11 +++++++++++
 test/box/net.box_discard_gh-3107.test.lua |  3 +++
 3 files changed, 15 insertions(+)

diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua
index 5fd8b96b079d..cacb7473deb0 100644
--- a/src/box/lua/net_box.lua
+++ b/src/box/lua/net_box.lua
@@ -432,6 +432,7 @@ local function create_transport(host, port, user, password, callback,
             self.id = nil
             self.errno = box.error.PROC_LUA
             self.response = 'Response is discarded'
+            self.cond:broadcast()
         end
     end
 
diff --git a/test/box/net.box_discard_gh-3107.result b/test/box/net.box_discard_gh-3107.result
index 3498c9d5a9be..370a87c524b4 100644
--- a/test/box/net.box_discard_gh-3107.result
+++ b/test/box/net.box_discard_gh-3107.result
@@ -92,9 +92,20 @@ ret
 future = c:call('long_function', {1, 2, 3}, {is_async = true})
 ---
 ...
+ch = fiber.channel()
+---
+...
+_ = fiber.create(function() ch:put({future:wait_result()}) end)
+---
+...
 future:discard()
 ---
 ...
+ch:get(100)
+---
+- - null
+  - Response is discarded
+...
 finalize_long()
 ---
 ...
diff --git a/test/box/net.box_discard_gh-3107.test.lua b/test/box/net.box_discard_gh-3107.test.lua
index 71f08a411422..89f177fa811f 100644
--- a/test/box/net.box_discard_gh-3107.test.lua
+++ b/test/box/net.box_discard_gh-3107.test.lua
@@ -33,7 +33,10 @@ ret
 -- Test discard.
 --
 future = c:call('long_function', {1, 2, 3}, {is_async = true})
+ch = fiber.channel()
+_ = fiber.create(function() ch:put({future:wait_result()}) end)
 future:discard()
+ch:get(100)
 finalize_long()
 future:result()
 future:wait_result(100)
-- 
2.25.1



More information about the Tarantool-patches mailing list