<div dir="ltr">Thanks!<br><br><div class="gmail_quote"><div dir="ltr">ср, 29 авг. 2018 г. в 12:03, Vladimir Davydov <<a href="mailto:vdavydov.dev@gmail.com">vdavydov.dev@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Aug 28, 2018 at 07:22:26PM +0300, Olga Arkhangelskaia wrote:<br>
> When we try to connect one master more than once we used to have<br>
> assertion instead of error.<br>
> <br>
> Closes #3610<br>
> ---<br>
> <a href="https://github.com/tarantool/tarantool/issues/3610" rel="noreferrer" target="_blank">https://github.com/tarantool/tarantool/issues/3610</a><br>
> <a href="https://github.com/tarantool/tarantool/tree/OKriw/assert_fail_when_connect_master_twice" rel="noreferrer" target="_blank">https://github.com/tarantool/tarantool/tree/OKriw/assert_fail_when_connect_master_twice</a><br>
<br>
Broken link.<br>
<br>
> <br>
>  src/box/box.cc            | 14 ++++++++++++++<br>
>  test/box-tap/cfg.test.lua |  8 +++++++-<br>
>  2 files changed, 21 insertions(+), 1 deletion(-)<br>
> <br>
> diff --git a/src/box/box.cc b/src/box/box.cc<br>
> index 8d7454d1f..3a571ae3c 100644<br>
> --- a/src/box/box.cc<br>
> +++ b/src/box/box.cc<br>
> @@ -369,9 +369,23 @@ static void<br>
>  box_check_replication(void)<br>
>  {<br>
>       int count = cfg_getarr_size("replication");<br>
> +     char *repl[count-1];<br>
>       for (int i = 0; i < count; i++) {<br>
>               const char *source = cfg_getarr_elem("replication", i);<br>
>               box_check_uri(source, "replication");<br>
> +             repl[i] = strdup(source);<br>
> +             if (repl[i] == NULL) {<br>
> +                     tnt_raise(OutOfMemory, sizeof(*source), "source", "malloc");<br>
> +             }<br>
> +             for (int j = i; j >= 1; j--) {<br>
> +                     if (strcmp(repl[i], repl[j-1]) == 0) {<br>
> +                             tnt_raise(ClientError, ER_CFG, "replication",<br>
> +                                       "duplication of replication source");<br>
> +                     }<br>
> +             }<br>
> +     }<br>
> +     for (int i = 0; i < count; i++) {<br>
> +             free(repl[i]);<br>
<br>
This is totally wrong, because different URLs can point to the same<br>
instance, e.g.<br>
<br>
Instance 1: box.cfg{listen = 12345}<br>
<br>
Instance 2: box.cfg{replication = {12345, 'localhost:12345'}}<br>
<br>
Crash.<br>
<br>
All you're supposed to do is fix the checks in replication.cc<br></blockquote><div><br></div><div><br></div><div>I am a bit lost. We have to raise an exception when have duplication uri, or or just skip duplication?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
>       }<br>
>  }<br>
>  <br>
> diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua<br>
> index 5e72004ca..b227c5edb 100755<br>
> --- a/test/box-tap/cfg.test.lua<br>
> +++ b/test/box-tap/cfg.test.lua<br>
> @@ -6,7 +6,7 @@ local socket = require('socket')<br>
>  local fio = require('fio')<br>
>  local uuid = require('uuid')<br>
>  local msgpack = require('msgpack')<br>
> -test:plan(90)<br>
> +test:plan(91)<br>
>  <br>
>  --------------------------------------------------------------------------------<br>
>  -- Invalid values<br>
> @@ -446,5 +446,11 @@ code = string.format(code_fmt, dir, instance_uuid, uuid.new())<br>
>  test:is(run_script(code), PANIC, "replicaset_uuid mismatch")<br>
>  fio.rmdir(dir)<br>
>  <br>
> +--<br>
> +--gh-3610: assertion failure when trying to connect to the same master more than once<br>
> +--<br>
> +status, reason = pcall(box.cfg, {listen = 3303, replication={3303,3303}})<br>
> +test:ok(not status and reason:match("Incorrect"), "Duplication of replication source")<br>
> +<br>
<br>
The test passes with and without your patch, i.e. useless.<br>
<br>
Besides, it doesn't test all cases described in the issue.<br></blockquote><div><br></div><div>will fix </div></div></div>