[tarantool-patches] [PATCH] Don't throw an exception in a replication handler

Georgy Kirichenko georgy at tarantool.org
Thu Aug 23 19:00:31 MSK 2018


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





More information about the Tarantool-patches mailing list