Tarantool development patches archive
 help / color / mirror / Atom feed
* [PATCH v2] replication: fix bug with zero replication_connect_quorum
@ 2018-04-09 10:35 Konstantin Belyavskiy
  2018-04-09 14:07 ` Vladimir Davydov
  0 siblings, 1 reply; 2+ messages in thread
From: Konstantin Belyavskiy @ 2018-04-09 10:35 UTC (permalink / raw)
  To: vdavydov, georgy; +Cc: tarantool-patches

If 'box.cfg.read_only' is false, 'replication' defines at least one
replica (other than itself), but they are not available at the time
of box.cfg execution and replication_connect_quorum is set to zero,
master displays 'orphan' status instead of 'running' since logic
which cnange this state is executed only after successfull connection.

Changes in v2:
Change test to @locker version.

ticket: https://github.com/tarantool/tarantool/issues/3278
branch: https://github.com/tarantool/tarantool/compare/gh-3278-fix-bug-with-zero-replication-connect-quorum

Closes #3278
---
 src/box/replication.cc                 |  8 +++--
 test/replication/quorum.result         | 66 ++++++++++++++++++++++++++++++++++
 test/replication/quorum.test.lua       | 22 ++++++++++++
 test/replication/replica_no_quorum.lua | 11 ++++++
 4 files changed, 105 insertions(+), 2 deletions(-)
 create mode 100644 test/replication/replica_no_quorum.lua

diff --git a/src/box/replication.cc b/src/box/replication.cc
index b1c84d36c..760f83751 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -600,8 +600,12 @@ error:
 void
 replicaset_follow(void)
 {
-	if (replicaset.applier.total == 0) {
-		/* Replication is not configured. */
+	if (replicaset.applier.total == 0 || replicaset_quorum() == 0) {
+		/*
+		 * Replication is not configured or quorum is set to
+		 * zero so in the latter case we have no need to wait
+		 * for others.
+		 */
 		box_clear_orphan();
 		return;
 	}
diff --git a/test/replication/quorum.result b/test/replication/quorum.result
index 34408d421..909bfb55b 100644
--- a/test/replication/quorum.result
+++ b/test/replication/quorum.result
@@ -239,3 +239,69 @@ test_run:cmd('switch default')
 test_run:drop_cluster(SERVERS)
 ---
 ...
+--
+-- gh-3278: test different replication and replication_connect_quorum configs.
+--
+box.schema.user.grant('guest', 'replication')
+---
+...
+test_run:cmd("create server replica with rpl_master=default, script='replication/replica_no_quorum.lua'")
+---
+- true
+...
+test_run:cmd("start server replica")
+---
+- true
+...
+test_run:cmd("switch replica")
+---
+- true
+...
+box.info.status -- running
+---
+- running
+...
+test_run:cmd("switch default")
+---
+- true
+...
+test_run:cmd("stop server replica")
+---
+- true
+...
+listen = box.cfg.listen
+---
+...
+box.cfg{listen = ''}
+---
+...
+test_run:cmd("start server replica")
+---
+- true
+...
+test_run:cmd("switch replica")
+---
+- true
+...
+box.info.status -- running
+---
+- running
+...
+test_run:cmd("switch default")
+---
+- true
+...
+test_run:cmd("stop server replica")
+---
+- true
+...
+test_run:cmd("cleanup server replica")
+---
+- true
+...
+box.schema.user.revoke('guest', 'replication')
+---
+...
+box.cfg{listen = listen}
+---
+...
diff --git a/test/replication/quorum.test.lua b/test/replication/quorum.test.lua
index 856006843..a96dec759 100644
--- a/test/replication/quorum.test.lua
+++ b/test/replication/quorum.test.lua
@@ -97,3 +97,25 @@ box.info.replication[4].upstream.status
 -- Cleanup.
 test_run:cmd('switch default')
 test_run:drop_cluster(SERVERS)
+
+--
+-- gh-3278: test different replication and replication_connect_quorum configs.
+--
+
+box.schema.user.grant('guest', 'replication')
+test_run:cmd("create server replica with rpl_master=default, script='replication/replica_no_quorum.lua'")
+test_run:cmd("start server replica")
+test_run:cmd("switch replica")
+box.info.status -- running
+test_run:cmd("switch default")
+test_run:cmd("stop server replica")
+listen = box.cfg.listen
+box.cfg{listen = ''}
+test_run:cmd("start server replica")
+test_run:cmd("switch replica")
+box.info.status -- running
+test_run:cmd("switch default")
+test_run:cmd("stop server replica")
+test_run:cmd("cleanup server replica")
+box.schema.user.revoke('guest', 'replication')
+box.cfg{listen = listen}
diff --git a/test/replication/replica_no_quorum.lua b/test/replication/replica_no_quorum.lua
new file mode 100644
index 000000000..b9edeea94
--- /dev/null
+++ b/test/replication/replica_no_quorum.lua
@@ -0,0 +1,11 @@
+#!/usr/bin/env tarantool
+
+box.cfg({
+    listen              = os.getenv("LISTEN"),
+    replication         = os.getenv("MASTER"),
+    memtx_memory        = 107374182,
+    replication_connect_quorum = 0,
+    replication_connect_timeout = 0.1,
+})
+
+require('console').listen(os.getenv('ADMIN'))
-- 
2.14.3 (Apple Git-98)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] replication: fix bug with zero replication_connect_quorum
  2018-04-09 10:35 [PATCH v2] replication: fix bug with zero replication_connect_quorum Konstantin Belyavskiy
@ 2018-04-09 14:07 ` Vladimir Davydov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Davydov @ 2018-04-09 14:07 UTC (permalink / raw)
  To: Konstantin Belyavskiy; +Cc: georgy, tarantool-patches

The patch looks good to me.

On Mon, Apr 09, 2018 at 01:35:30PM +0300, Konstantin Belyavskiy wrote:
> If 'box.cfg.read_only' is false, 'replication' defines at least one
> replica (other than itself), but they are not available at the time
> of box.cfg execution and replication_connect_quorum is set to zero,
> master displays 'orphan' status instead of 'running' since logic
> which cnange this state is executed only after successfull connection.
> 

> Changes in v2:
> Change test to @locker version.
> 
> ticket: https://github.com/tarantool/tarantool/issues/3278
> branch: https://github.com/tarantool/tarantool/compare/gh-3278-fix-bug-with-zero-replication-connect-quorum

This should go after --- below (it is ignored by git-am then).

> 
> Closes #3278
> ---
>  src/box/replication.cc                 |  8 +++--
>  test/replication/quorum.result         | 66 ++++++++++++++++++++++++++++++++++
>  test/replication/quorum.test.lua       | 22 ++++++++++++
>  test/replication/replica_no_quorum.lua | 11 ++++++
>  4 files changed, 105 insertions(+), 2 deletions(-)
>  create mode 100644 test/replication/replica_no_quorum.lua

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-04-09 14:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09 10:35 [PATCH v2] replication: fix bug with zero replication_connect_quorum Konstantin Belyavskiy
2018-04-09 14:07 ` Vladimir Davydov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox