[PATCH v2 1/2] iproto: update readahead in existing connections

Serge Petrenko sergepetrenko at tarantool.org
Thu Feb 21 21:02:35 MSK 2019


Iproto connections keep old readahead values for input buffers even
after box.cfg.readahead reconfiguration. This means that for the changes
to take place for the old clients, they have to reconnect. Otherwise
tarantool log will be spammed with 'readahead limit is reached' errors.

To fix this, start updating input buffer size for iproto connections
if needed every time the buffer is empty.

Closes: #3958
---
 src/box/iproto.cc         |  5 ++++
 test/box/net.box.result   | 62 +++++++++++++++++++++++++++++++++++++++
 test/box/net.box.test.lua | 37 +++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/src/box/iproto.cc b/src/box/iproto.cc
index a08c8c5cb..7a1d3bfd0 100644
--- a/src/box/iproto.cc
+++ b/src/box/iproto.cc
@@ -670,6 +670,11 @@ iproto_connection_input_buffer(struct iproto_connection *con)
 		 */
 		return NULL;
 	}
+	/* Update buffer size if readahead has changed. */
+	if (new_ibuf->start_capacity != iproto_readahead) {
+		ibuf_destroy(new_ibuf);
+		ibuf_create(new_ibuf, cord_slab_cache(), iproto_readahead);
+	}
 
 	ibuf_reserve_xc(new_ibuf, to_read + con->parse_size);
 	/*
diff --git a/test/box/net.box.result b/test/box/net.box.result
index 6351898b3..d143f98f6 100644
--- a/test/box/net.box.result
+++ b/test/box/net.box.result
@@ -3452,3 +3452,65 @@ box.schema.user.revoke('guest', 'read,write', 'space', '_space')
 box.schema.user.revoke('guest', 'create', 'space')
 ---
 ...
+--
+-- gh-3958 updating box.cfg.readahead doesn't affect existing connections.
+--
+-- purge old 'readahead limit is reached' messages from the log.
+test_run:cmd("restart server default")
+netbox = require('net.box')
+---
+...
+readahead = box.cfg.readahead
+---
+...
+box.cfg{readahead = 128}
+---
+...
+s = box.schema.space.create("test")
+---
+...
+_ = s:create_index("pk")
+---
+...
+box.schema.user.grant("guest", "read,write", "space", "test")
+---
+...
+-- connection is created with small readahead value,
+-- make sure it is updated if box.cfg.readahead is changed.
+c = netbox.connect(box.cfg.listen)
+---
+...
+box.cfg{readahead = 100 * 1024}
+---
+...
+box.error.injection.set("ERRINJ_WAL_DELAY", true)
+---
+- ok
+...
+test_run:cmd('setopt delimiter ";"')
+---
+- true
+...
+local pad = string.rep('x', 8192)
+for i = 1,5 do
+        c.space.test:replace({i, pad}, {is_async=true})
+end;
+---
+...
+test_run:cmd('setopt delimiter ""');
+---
+- true
+...
+box.error.injection.set("ERRINJ_WAL_DELAY", false)
+---
+- ok
+...
+test_run:wait_log('default', 'readahead limit is reached', nil, 1.0)
+---
+...
+s:drop()
+---
+...
+box.cfg{readahead = readahead}
+---
+...
diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua
index 6c527f506..d69a4ee73 100644
--- a/test/box/net.box.test.lua
+++ b/test/box/net.box.test.lua
@@ -1397,3 +1397,40 @@ box.schema.func.drop('do_long')
 box.schema.user.revoke('guest', 'write', 'space', '_schema')
 box.schema.user.revoke('guest', 'read,write', 'space', '_space')
 box.schema.user.revoke('guest', 'create', 'space')
+
+--
+-- gh-3958 updating box.cfg.readahead doesn't affect existing connections.
+--
+-- purge old 'readahead limit is reached' messages from the log.
+test_run:cmd("restart server default")
+netbox = require('net.box')
+
+readahead = box.cfg.readahead
+
+box.cfg{readahead = 128}
+
+s = box.schema.space.create("test")
+_ = s:create_index("pk")
+box.schema.user.grant("guest", "read,write", "space", "test")
+
+-- connection is created with small readahead value,
+-- make sure it is updated if box.cfg.readahead is changed.
+c = netbox.connect(box.cfg.listen)
+
+box.cfg{readahead = 100 * 1024}
+
+box.error.injection.set("ERRINJ_WAL_DELAY", true)
+
+test_run:cmd('setopt delimiter ";"')
+local pad = string.rep('x', 8192)
+for i = 1,5 do
+        c.space.test:replace({i, pad}, {is_async=true})
+end;
+test_run:cmd('setopt delimiter ""');
+
+box.error.injection.set("ERRINJ_WAL_DELAY", false)
+
+test_run:wait_log('default', 'readahead limit is reached', nil, 1.0)
+
+s:drop()
+box.cfg{readahead = readahead}
-- 
2.17.2 (Apple Git-113)




More information about the Tarantool-patches mailing list