<HTML><BODY><br><br><br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;">
        Суббота,  7 апреля 2018, 17:55 +03:00 от Vladimir Davydov <vdavydov.dev@gmail.com>:<br><br><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_15231129530000000279_BODY">On Fri, Apr 06, 2018 at 11:39:45AM +0300, Konstantin Belyavskiy wrote:<br>
                                 > If 'box.cfg.read_only' is false, 'replication' defines at least one<br>
> replica (other than itself), but they are not available at the time<br>
> of box.cfg execution and replication_connect_quorum is set to zero,<br>
> master displays 'orphan' status instead of 'running' since logic<br>
> which cnange this state is executed only after successfull connection.<br>
> <br>
> Closes #3278<br>
> ---<br>
> ticket: <a href="https://github.com/tarantool/tarantool/issues/3278" target="_blank">https://github.com/tarantool/tarantool/issues/3278</a><br>
> branch: <a href="https://github.com/tarantool/tarantool/compare/gh-3278-fix-bug-with-zero-replication-connect-quorum" target="_blank">https://github.com/tarantool/tarantool/compare/gh-3278-fix-bug-with-zero-replication-connect-quorum</a><br>
> <br>
>  src/box/replication.cc                 |  8 +++-<br>
>  test/replication/check_quorum.result   | 86 ++++++++++++++++++++++++++++++++++<br>
>  test/replication/check_quorum.test.lua | 30 ++++++++++++<br>
>  test/replication/replica_params.lua    | 21 +++++++++<br>
>  4 files changed, 143 insertions(+), 2 deletions(-)<br>
>  create mode 100644 test/replication/check_quorum.result<br>
>  create mode 100644 test/replication/check_quorum.test.lua<br>
>  create mode 100644 test/replication/replica_params.lua<br><br>
> diff --git a/test/replication/check_quorum.test.lua b/test/replication/check_quorum.test.lua<br><br>
This test case should be a part of replication/quorum.test.lua</div></div></div></div></blockquote>Replace<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_15231129530000000279_BODY"><br>
> new file mode 100644<br>
> index 000000000..497d2af6c<br>
> --- /dev/null<br>
> +++ b/test/replication/check_quorum.test.lua<br>
> @@ -0,0 +1,30 @@<br>
> +--<br>
> +-- gh-3278: test different replication and replication_connect_quorum configs.<br>
> +--<br>
> +<br><br>
This test passes with and without the fix, i.e. it is pointless:<br>
it is supposed to test the case of replication_connect_quorum=0,<br>
but it only sets this parameter to 1 or 2.</div></div></div></div></blockquote>Yes, sorry, want to test also old behaviour to not break backward capability and also<br>check cases in ticket, but forgot to add main case. Fixed.<br>And removed all others to make it shorter.<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_15231129530000000279_BODY"><br>
> +env = require('test_run')<br>
> +test_run = env.new()<br>
> +socket = require('socket')<br>
> +s = socket.tcp_server('localhost', 3371, function() end)<br><br>
Do not use an arbitrary tcp port as it may be busy.</div></div></div></div></blockquote>Vladimir, please checkout latest version, already fixed, first find empty port, then pass as a param.<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_15231129530000000279_BODY"><br>
> +test_run:cmd('switch default')<br>
> +listen = os.getenv("LISTEN")<br>
> +box.cfg{listen = listen, replication_timeout = 1, read_only = false}<br>
> +box.info.status -- running<br>
> +test_run:cmd("restart server default")<br>
> +listen = os.getenv("LISTEN")<br>
> +box.cfg{listen = listen, replication = { listen }, replication_timeout = 1, read_only = false}<br>
> +box.info.status -- running<br>
> +test_run:cmd("restart server default")<br>
> +listen = os.getenv("LISTEN")<br>
> +box.cfg{listen = listen, replication = { listen }, replication_timeout = 1, read_only = false, replication_connect_quorum = 1}<br>
> +box.info.status -- running<br>
> +<br>
> +test_run:cmd("create server replica with rpl_master=default, script='replication/replica_params.lua'")<br>
> +test_run:cmd("start server replica with args='2 1'")<br><br>
Why don't you simply use the default server as replication master?<br>
Something like this:<br><br>
box.schema.user.grant('guest', 'replication')<br>
test_run:cmd("create server replica with rpl_master=default, script='replication/replica_quorum.lua'")<br>
test_run:cmd("start server replica")<br>
test_run:cmd("switch replica")<br>
box.info.status -- running<br>
test_run:cmd("switch default")<br>
test_run:cmd("stop server replica")<br>
listen = box.cfg.listen<br>
box.cfg{listen = ''}<br>
test_run:cmd("start server replica")<br>
test_run:cmd("switch replica")<br>
box.info.status -- running<br>
test_run:cmd("switch default")<br>
test_run:cmd("stop server replica")<br>
test_run:cmd("cleanup server replica")<br>
box.schema.user.revoke('guest', 'replication')<br>
box.cfg{listen = listen}</div></div></div></div></blockquote>Have to create separate scripts with parameters, since first have to do box.cfg{} without replication<br>and then with some unreachable.<br><blockquote style="border-left:1px solid #0857A6; margin:10px; padding:0 0 0 10px;"><div id=""><div class="js-helper js-readmsg-msg"><div><div id="style_15231129530000000279_BODY"><br>
> +test_run:cmd('switch replica')<br>
> +box.info.status -- running<br>
> +box.cfg{replication_connect_quorum = 1}<br>
> +test_run:cmd('switch default')<br>
> +test_run:cmd("restart server replica with args='2 2'")<br>
> +test_run:cmd('switch replica')<br>
> +box.info.status -- orphan<br>
> diff --git a/test/replication/replica_params.lua b/test/replication/replica_params.lua<br>
> new file mode 100644<br>
> index 000000000..73a15e6c3<br>
> --- /dev/null<br>
> +++ b/test/replication/replica_params.lua<br>
> @@ -0,0 +1,21 @@<br>
> +#!/usr/bin/env tarantool<br>
> +<br>
> +local quorum = tonumber(arg[1])<br>
> +local n_replics = tonumber(arg[2])<br>
> +listen = os.getenv("LISTEN")<br>
> +-- Test different replicaset configurations:<br>
> +-- First, when the only address in the replicaset is itself.<br>
> +repl = {listen}<br>
> +-- To test situation with second master unavailable, add<br>
> +-- second address (should be empty).<br>
> +if n_replics == 2 then repl = { listen, '127.0.0.1:3371' } end<br>
> +<br>
> +box.cfg({<br>
> +    listen              = listen,<br>
> +    replication         = repl,<br>
> +    memtx_memory        = 107374182,<br>
> +    replication_connect_quorum = quorum,<br>
> +    replication_connect_timeout = 0.1,<br>
> +})<br>
> +<br>
> +require('console').listen(os.getenv('ADMIN'))<br></div></div></div></div></blockquote>
<br>
<br>Best regards,<br>Konstantin Belyavskiy<br>k.belyavskiy@tarantool.org<br></BODY></HTML>