[tarantool-patches] [PATCH v2] Don't throw an exception in a replication handler
Vladimir Davydov
vdavydov.dev at gmail.com
Mon Aug 27 12:44:58 MSK 2018
On Mon, Aug 27, 2018 at 09:43:46AM +0300, Georgy Kirichenko wrote:
> diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua
> index c60adf5a5..e72ae7cda 100644
> --- a/test/replication/misc.test.lua
> +++ b/test/replication/misc.test.lua
> @@ -90,6 +90,51 @@ box.space.space1:drop()
> test_run:cmd("switch default")
> test_run:drop_cluster(SERVERS)
>
> +ffi = require('ffi')
> +test_run:cmd("setopt delimiter ';;'")
> +ffi.cdef([[
> +typedef long rlim_t;
> +struct rlimit {
> + rlim_t rlim_cur; /* Soft limit */
> + rlim_t rlim_max; /* Hard limit (ceiling for rlim_cur) */
> +};
> +int getrlimit(int resource, struct rlimit *rlim);
> +int setrlimit(int resource, const struct rlimit *rlim);
> +]]);;
> +test_run:cmd("setopt delimiter ''");;
When run twice in a row, like this:
./test-run -j -1 replication/misc.test.lua replication/misc.test.lua
The test fails with:
Test failed! Result content mismatch:
--- replication/misc.result Mon Aug 27 12:27:09 2018
+++ replication/misc.reject Mon Aug 27 12:43:48 2018
@@ -246,6 +246,7 @@
int setrlimit(int resource, const struct rlimit *rlim);
]]);;
---
+- error: attempt to redefine 'rlimit'
...
test_run:cmd("setopt delimiter ''");;
---
Please fix. I think you should fix that by defining rlimit in a lua
module.
> +
> +rlim = ffi.new('struct rlimit')
> +ffi.C.getrlimit(7 --[[RLIMIT_NOFILE]], rlim)
> +old_rlim = rlim.rlim_cur
> +rlim.rlim_cur = 64
> +ffi.C.setrlimit(7 --[[RLIMIT_NOFILE]], rlim)
> +
> +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')
> +test_run = require('test_run').new()
> +fiber = require('fiber')
> +test_run:cmd("setopt delimiter ';'")
> +for i = 1, 64 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("setopt delimiter ''");
> +
> +box.info.replication[1].upstream.status
> +
> +test_run:cmd('switch default')
> +
> +rlim.rlim_cur = old_rlim
> +ffi.C.setrlimit(7 --[[RLIMIT_NOFILE]], rlim)
Nit: IMO better define RLIMIT_NOFILE = 7 in Lua.
> +
> +test_run:cmd('stop server sock')
> +test_run:cmd('cleanup server sock')
> +
> box.schema.user.revoke('guest', 'replication')
More information about the Tarantool-patches
mailing list