Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [Tarantool-patches] [PATCH 1/1] replication: auto reconnect if password is invalid
Date: Thu, 17 Oct 2019 23:16:37 +0200	[thread overview]
Message-ID: <d848d875e3fa5dbb313546a963703effa239cdff.1571346959.git.v.shpilevoy@tarantool.org> (raw)

Before the patch there was a race in replication
password configuration. It was possible that a replica
connects to a master with a custom password before
that password is actually set. The replica treated the
error as critical and exited.

But in fact it is not critical. Replica even can
withstand absence of a user and keeps reconnecting.
Wrong password situation arises from the same problem
of non atomic configuration and is fixed the same -
keep reconnect attempts if the password was wrong.

Closes #4550
---
Branch: https://github.com/tarantool/tarantool/tree/gerold103/gh-4550-replication-password-cfg

 src/box/applier.cc             |  4 +++-
 test/replication/misc.result   | 16 +++++++++++++---
 test/replication/misc.test.lua | 12 +++++++++---
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 6239fcfd3..7d4a670d7 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -101,6 +101,7 @@ applier_log_error(struct applier *applier, struct error *e)
 	case ER_NO_SUCH_USER:
 	case ER_SYSTEM:
 	case ER_UNKNOWN_REPLICA:
+	case ER_PASSWORD_MISMATCH:
 		say_info("will retry every %.2lf second",
 			 replication_reconnect_interval());
 		break;
@@ -979,7 +980,8 @@ applier_f(va_list ap)
 				goto reconnect;
 			} else if (e->errcode() == ER_CFG ||
 				   e->errcode() == ER_ACCESS_DENIED ||
-				   e->errcode() == ER_NO_SUCH_USER) {
+				   e->errcode() == ER_NO_SUCH_USER ||
+				   e->errcode() == ER_PASSWORD_MISMATCH) {
 				/* Invalid configuration */
 				applier_log_error(applier, e);
 				applier_disconnect(applier, APPLIER_LOADING);
diff --git a/test/replication/misc.result b/test/replication/misc.result
index f7098aac8..b63d72846 100644
--- a/test/replication/misc.result
+++ b/test/replication/misc.result
@@ -374,8 +374,10 @@ test_run:cleanup_cluster()
 ---
 ...
 --
--- Test case for gh-3637. Before the fix replica would exit with
--- an error. Now check that we don't hang and successfully connect.
+-- Test case for gh-3637, gh-4550. Before the fix replica would
+-- exit with an error if a user does not exist or a password is
+-- incorrect. Now check that we don't hang/panic and successfully
+-- connect.
 --
 fiber = require('fiber')
 ---
@@ -392,7 +394,15 @@ test_run:cmd("start server replica_auth with wait=False, wait_load=False, args='
 fiber.sleep(0.1)
 ---
 ...
-box.schema.user.create('cluster', {password='pass'})
+box.schema.user.create('cluster')
+---
+...
+-- The user is created. Let the replica fail auth request due to
+-- a wrong password.
+fiber.sleep(0.1)
+---
+...
+box.schema.user.passwd('cluster', 'pass')
 ---
 ...
 box.schema.user.grant('cluster', 'replication')
diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua
index c4ddbdb47..c454a0992 100644
--- a/test/replication/misc.test.lua
+++ b/test/replication/misc.test.lua
@@ -153,15 +153,21 @@ test_run:cmd('delete server er_load2')
 test_run:cleanup_cluster()
 
 --
--- Test case for gh-3637. Before the fix replica would exit with
--- an error. Now check that we don't hang and successfully connect.
+-- Test case for gh-3637, gh-4550. Before the fix replica would
+-- exit with an error if a user does not exist or a password is
+-- incorrect. Now check that we don't hang/panic and successfully
+-- connect.
 --
 fiber = require('fiber')
 test_run:cmd("create server replica_auth with rpl_master=default, script='replication/replica_auth.lua'")
 test_run:cmd("start server replica_auth with wait=False, wait_load=False, args='cluster:pass 0.05'")
 -- Wait a bit to make sure replica waits till user is created.
 fiber.sleep(0.1)
-box.schema.user.create('cluster', {password='pass'})
+box.schema.user.create('cluster')
+-- The user is created. Let the replica fail auth request due to
+-- a wrong password.
+fiber.sleep(0.1)
+box.schema.user.passwd('cluster', 'pass')
 box.schema.user.grant('cluster', 'replication')
 
 while box.info.replication[2] == nil do fiber.sleep(0.01) end
-- 
2.21.0 (Apple Git-122)

             reply	other threads:[~2019-10-17 21:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17 21:16 Vladislav Shpilevoy [this message]
2019-10-17 22:28 ` Konstantin Osipov
2019-10-17 22:43   ` [Tarantool-patches] [tarantool-patches] " Vladislav Shpilevoy
2019-10-28  6:19 ` [Tarantool-patches] [tarantool-patches] " Kirill Yukhin
2019-11-14 11:20   ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d848d875e3fa5dbb313546a963703effa239cdff.1571346959.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [Tarantool-patches] [PATCH 1/1] replication: auto reconnect if password is invalid' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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