diff --git a/src/box/iproto.cc b/src/box/iproto.cc index a08c8c5cbadd1aa9cbd96b47fc2332e5117ae223..7a1d3bfd094bbdcb0fbcf9bdbae9727a3ab16c6c 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 6351898b3a94142e17ba8c5db7ecc4239d02e2a4..b800531b4892cbd51d16278b57c45b606fd25b2d 100644 --- a/test/box/net.box.result +++ b/test/box/net.box.result @@ -3452,3 +3452,52 @@ 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. +-- +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 = net.connect(box.cfg.listen) +--- +... +box.cfg{readahead = 100 * 1024} +--- +... +box.error.injection.set("ERRINJ_WAL_DELAY", true) +--- +- ok +... +pad = string.rep('x', 8192) +--- +... +for i = 1, 5 do c.space.test:replace({i, pad}, {is_async = true}) end +--- +... +box.error.injection.set("ERRINJ_WAL_DELAY", false) +--- +- ok +... +test_run:wait_log('default', 'readahead limit is reached', 1024, 0.1) +--- +... +s:drop() +--- +... +box.cfg{readahead = readahead} +--- +... diff --git a/test/box/net.box.test.lua b/test/box/net.box.test.lua index 6c527f506a9568cb2a54471fd2a7669f7b570c0d..9e5ecfa0dd0d55019cbe945f82e52eb7810b90cd 100644 --- a/test/box/net.box.test.lua +++ b/test/box/net.box.test.lua @@ -1397,3 +1397,30 @@ 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. +-- +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 = net.connect(box.cfg.listen) + +box.cfg{readahead = 100 * 1024} + +box.error.injection.set("ERRINJ_WAL_DELAY", true) +pad = string.rep('x', 8192) +for i = 1, 5 do c.space.test:replace({i, pad}, {is_async = true}) end +box.error.injection.set("ERRINJ_WAL_DELAY", false) + +test_run:wait_log('default', 'readahead limit is reached', 1024, 0.1) + +s:drop() +box.cfg{readahead = readahead}