From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com Subject: [PATCH 1/1] netbox: discard all requests on a connection close Date: Sun, 19 Aug 2018 16:35:22 +0300 [thread overview] Message-ID: <87e7481bf5617598e1bb267650aa247a75120f68.1534685653.git.v.shpilevoy@tarantool.org> (raw) Their responses are unreachable now since the socket is closed. The bug was introduced by me during big netbox refactoring and removal of requests retries here: 62ba7ba762. Such requests evidently can be discarded immediately. Closes #3629 --- https://github.com/tarantool/tarantool/tree/gerold103/gh-3629-netbox-leaks-again https://github.com/tarantool/tarantool/issues/3629 src/box/lua/net_box.lua | 3 ++- test/box/net.box.result | 43 +++++++++++++++++++++++++++++++++++++++++-- test/box/net.box.test.lua | 16 ++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua index f5176ae13..fd6ebf9de 100644 --- a/src/box/lua/net_box.lua +++ b/src/box/lua/net_box.lua @@ -393,7 +393,8 @@ local function create_transport(host, port, user, password, callback, last_error = new_error callback('state_changed', new_state, new_errno, new_error) state_cond:broadcast() - if state == 'error' or state == 'error_reconnect' then + if state == 'error' or state == 'error_reconnect' or + state == 'closed' then for _, request in pairs(requests) do request.id = nil request.errno = new_errno diff --git a/test/box/net.box.result b/test/box/net.box.result index 37ac54658..4c4bcfafe 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -2942,12 +2942,12 @@ c:close() future2:wait_result(100) --- - null -- Connection is not established +- Connection closed ... future2:result() --- - null -- Connection is not established +- Connection closed ... future2:discard() --- @@ -3122,6 +3122,45 @@ test_run:grep_log('default', 'too big packet size in the header') ~= nil --- - true ... +-- +-- gh-3629: netbox leaks when a connection is closed deliberately +-- and it has non-finished requests. +-- +ready = false +--- +... +ok = nil +--- +... +err = nil +--- +... +c = net:connect(box.cfg.listen) +--- +... +function do_long() while not ready do fiber.sleep(0.01) end end +--- +... +f = fiber.create(function() ok, err = pcall(c.call, c, 'do_long') end) +--- +... +while f:status() ~= 'suspended' do fiber.sleep(0.01) end +--- +... +c:close() +--- +... +ready = true +--- +... +while not err do fiber.sleep(0.01) end +--- +... +ok, err +--- +- false +- Connection closed +... box.schema.user.revoke('guest', 'read,write,execute', 'universe') --- ... diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 56b656cc5..9a5e0a068 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -1263,4 +1263,20 @@ c._transport.perform_request(nil, nil, 'inject', nil, nil, data) c:close() test_run:grep_log('default', 'too big packet size in the header') ~= nil +-- +-- gh-3629: netbox leaks when a connection is closed deliberately +-- and it has non-finished requests. +-- +ready = false +ok = nil +err = nil +c = net:connect(box.cfg.listen) +function do_long() while not ready do fiber.sleep(0.01) end end +f = fiber.create(function() ok, err = pcall(c.call, c, 'do_long') end) +while f:status() ~= 'suspended' do fiber.sleep(0.01) end +c:close() +ready = true +while not err do fiber.sleep(0.01) end +ok, err + box.schema.user.revoke('guest', 'read,write,execute', 'universe') -- 2.15.2 (Apple Git-101.1)
next reply other threads:[~2018-08-19 13:35 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-19 13:35 Vladislav Shpilevoy [this message] 2018-08-20 16:57 ` Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=87e7481bf5617598e1bb267650aa247a75120f68.1534685653.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH 1/1] netbox: discard all requests on a connection close' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox