Tarantool development patches archive
 help / color / mirror / Atom feed
From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Georgy Kirichenko <georgy@tarantool.org>
Subject: [tarantool-patches] [PATCH] Don't throw an exception in a replication handler
Date: Thu, 23 Aug 2018 19:00:31 +0300	[thread overview]
Message-ID: <d68e3db84a03c216e292d4d701980623aa82113e.1535039855.git.georgy@tarantool.org> (raw)

It is an error to throw an error out of a cbus message handler because
it breaks cbus message delivery. In case of replication throwing an
error prevents iproto against replication socket closing.

Fixes 3642
---
Branch:
https://github.com/tarantool/tarantool/tree/g.kirichenko/gh-3642-fix-replication-socket-leak
Issue: https://github.com/tarantool/tarantool/issues/3642
 src/box/iproto.cc              |  2 +-
 test/replication/misc.test.lua | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index 0b92c316e..df32e4f2b 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -1412,7 +1412,7 @@ tx_process_join_subscribe(struct cmsg *m)
 			unreachable();
 		}
 	} catch (SocketError *e) {
-		throw; /* don't write error response to prevent SIGPIPE */
+		return; /* don't write error response to prevent SIGPIPE */
 	} catch (Exception *e) {
 		iproto_write_error(con->input.fd, e, ::schema_version,
 				   msg->header.sync);
diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua
index 850579769..32ab07924 100644
--- a/test/replication/misc.test.lua
+++ b/test/replication/misc.test.lua
@@ -79,4 +79,14 @@ box.space.space1:drop()
 test_run:cmd("switch default")
 test_run:drop_cluster(SERVERS)
 
+test_run:cmd('create server sock with rpl_master=default, script="replication/replica.lua"')
+test_run:cmd(string.format('start server sock'))
+test_run:cmd('switch sock')
+fiber = require('fiber')
+k = tonumber(io.popen('ulimit -n'):read())
+for i = 2, k > 1024 and 1 or k + 20 do local replication = box.cfg.replication box.cfg{replication = {}} box.cfg{replication = replication} while box.info.replication[1].upstream.status ~= 'follow' do fiber.sleep(0.0001) end end
+test_run:cmd('switch default')
+test_run:cmd('stop server sock')
+test_run:cmd('cleanup server sock')
+
 box.schema.user.revoke('guest', 'replication')
-- 
2.18.0

             reply	other threads:[~2018-08-23 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 16:00 Georgy Kirichenko [this message]
2018-08-23 19:57 ` Vladimir Davydov
2018-08-27 13:28 Georgy Kirichenko
2018-08-27 15:36 ` Vladimir Davydov
2018-08-28 10:16 ` 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=d68e3db84a03c216e292d4d701980623aa82113e.1535039855.git.georgy@tarantool.org \
    --to=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH] Don'\''t throw an exception in a replication handler' \
    /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