summaryrefslogtreecommitdiff
path: root/sql/wsrep_sst.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-05-10 09:09:50 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-05-10 09:09:50 +0300
commit98e6159892ae36d4ab82ce8f43b7e7bc0ab6bfa2 (patch)
treea9cd2b7610de5500583fe726a97fb8705bc6ccec /sql/wsrep_sst.cc
parent72753d2b65fe375d23954b877a48350adadeb4e4 (diff)
parentd0785f773188b5f0eebb3135b320b2bac628f2f2 (diff)
downloadmariadb-git-98e6159892ae36d4ab82ce8f43b7e7bc0ab6bfa2.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql/wsrep_sst.cc')
-rw-r--r--sql/wsrep_sst.cc95
1 files changed, 51 insertions, 44 deletions
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index f16050866a6..eac5093ae2a 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -631,49 +631,30 @@ err:
return NULL;
}
-#define WSREP_SST_AUTH_ENV "WSREP_SST_OPT_AUTH"
+#define WSREP_SST_AUTH_ENV "WSREP_SST_OPT_AUTH"
+#define WSREP_SST_REMOTE_AUTH_ENV "WSREP_SST_OPT_REMOTE_AUTH"
+#define DATA_HOME_DIR_ENV "INNODB_DATA_HOME_DIR"
-static int sst_append_auth_env(wsp::env& env, const char* sst_auth)
+static int sst_append_env_var(wsp::env& env,
+ const char* const var,
+ const char* const val)
{
- int const sst_auth_size= strlen(WSREP_SST_AUTH_ENV) + 1 /* = */
- + (sst_auth ? strlen(sst_auth) : 0) + 1 /* \0 */;
+ int const env_str_size= strlen(var) + 1 /* = */
+ + (val ? strlen(val) : 0) + 1 /* \0 */;
- wsp::string sst_auth_str(sst_auth_size); // for automatic cleanup on return
- if (!sst_auth_str()) return -ENOMEM;
+ wsp::string env_str(env_str_size); // for automatic cleanup on return
+ if (!env_str()) return -ENOMEM;
- int ret= snprintf(sst_auth_str(), sst_auth_size, "%s=%s",
- WSREP_SST_AUTH_ENV, sst_auth ? sst_auth : "");
+ int ret= snprintf(env_str(), env_str_size, "%s=%s", var, val ? val : "");
- if (ret < 0 || ret >= sst_auth_size)
+ if (ret < 0 || ret >= env_str_size)
{
- WSREP_ERROR("sst_append_auth_env(): snprintf() failed: %d", ret);
+ WSREP_ERROR("sst_append_env_var(): snprintf(%s=%s) failed: %d",
+ var, val, ret);
return (ret < 0 ? ret : -EMSGSIZE);
}
- env.append(sst_auth_str());
- return -env.error();
-}
-
-#define DATA_HOME_DIR_ENV "INNODB_DATA_HOME_DIR"
-
-static int sst_append_data_dir(wsp::env& env, const char* data_dir)
-{
- int const data_dir_size= strlen(DATA_HOME_DIR_ENV) + 1 /* = */
- + (data_dir ? strlen(data_dir) : 0) + 1 /* \0 */;
-
- wsp::string data_dir_str(data_dir_size); // for automatic cleanup on return
- if (!data_dir_str()) return -ENOMEM;
-
- int ret= snprintf(data_dir_str(), data_dir_size, "%s=%s",
- DATA_HOME_DIR_ENV, data_dir ? data_dir : "");
-
- if (ret < 0 || ret >= data_dir_size)
- {
- WSREP_ERROR("sst_append_data_dir(): snprintf() failed: %d", ret);
- return (ret < 0 ? ret : -EMSGSIZE);
- }
-
- env.append(data_dir_str());
+ env.append(env_str());
return -env.error();
}
@@ -1084,7 +1065,7 @@ static ssize_t sst_prepare_other (const char* method,
return -env.error();
}
- if ((ret= sst_append_auth_env(env, sst_auth)))
+ if ((ret= sst_append_env_var(env, WSREP_SST_AUTH_ENV, sst_auth)))
{
WSREP_ERROR("sst_prepare_other(): appending auth failed: %d", ret);
return ret;
@@ -1092,7 +1073,7 @@ static ssize_t sst_prepare_other (const char* method,
if (data_home_dir)
{
- if ((ret= sst_append_data_dir(env, data_home_dir)))
+ if ((ret= sst_append_env_var(env, DATA_HOME_DIR_ENV, data_home_dir)))
{
WSREP_ERROR("sst_prepare_other(): appending data "
"directory failed: %d", ret);
@@ -1278,12 +1259,12 @@ ssize_t wsrep_sst_prepare (void** msg)
*msg = malloc (msg_len);
if (NULL != *msg) {
- char* const method_ptr(reinterpret_cast<char*>(*msg));
+ char* const method_ptr(static_cast<char*>(*msg));
strcpy (method_ptr, method);
char* const addr_ptr(method_ptr + method_len + 1);
strcpy (addr_ptr, addr_out);
- WSREP_INFO ("Prepared SST request: %s|%s", method_ptr, addr_ptr);
+ WSREP_DEBUG("Prepared SST request: %s|%s", method_ptr, addr_ptr);
}
else {
WSREP_ERROR("Failed to allocate SST request of size %zu. Can't continue.",
@@ -1736,6 +1717,7 @@ static int sst_donate_other (const char* method,
"wsrep_sst_%s "
WSREP_SST_OPT_ROLE " 'donor' "
WSREP_SST_OPT_ADDR " '%s' "
+ WSREP_SST_OPT_LPORT " '%u' "
WSREP_SST_OPT_SOCKET " '%s' "
WSREP_SST_OPT_DATA " '%s' "
"%s"
@@ -1743,7 +1725,8 @@ static int sst_donate_other (const char* method,
WSREP_SST_OPT_GTID_DOMAIN_ID " '%d'"
"%s"
"%s",
- method, addr, mysqld_unix_port, mysql_real_data_home,
+ method, addr, mysqld_port, mysqld_unix_port,
+ mysql_real_data_home,
wsrep_defaults_file,
uuid, (long long) seqno, wsrep_gtid_domain_id,
binlog_opt_val,
@@ -1823,7 +1806,21 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
const char* data = method + method_len + 1;
- if (check_request_str(data, address_char))
+ /* check for auth@addr separator */
+ const char* addr= strrchr(data, '@');
+ wsp::string remote_auth;
+ if (addr)
+ {
+ remote_auth.set(strndup(data, addr - data));
+ addr++;
+ }
+ else
+ {
+ // no auth part
+ addr= data;
+ }
+
+ if (check_request_str(addr, address_char))
{
WSREP_ERROR("Bad SST address string. SST canceled.");
return WSREP_CB_FAILURE;
@@ -1844,15 +1841,25 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
}
int ret;
- if ((ret= sst_append_auth_env(env, sst_auth_real)))
+ if ((ret= sst_append_env_var(env, WSREP_SST_AUTH_ENV, sst_auth_real)))
{
WSREP_ERROR("wsrep_sst_donate_cb(): appending auth env failed: %d", ret);
return WSREP_CB_FAILURE;
}
+ if (remote_auth())
+ {
+ if ((ret= sst_append_env_var(env, WSREP_SST_REMOTE_AUTH_ENV,remote_auth())))
+ {
+ WSREP_ERROR("wsrep_sst_donate_cb(): appending remote auth env failed: "
+ "%d", ret);
+ return WSREP_CB_FAILURE;
+ }
+ }
+
if (data_home_dir)
{
- if ((ret= sst_append_data_dir(env, data_home_dir)))
+ if ((ret= sst_append_env_var(env, DATA_HOME_DIR_ENV, data_home_dir)))
{
WSREP_ERROR("wsrep_sst_donate_cb(): appending data "
"directory failed: %d", ret);
@@ -1862,12 +1869,12 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
if (!strcmp (WSREP_SST_MYSQLDUMP, method))
{
- ret = sst_donate_mysqldump(data, &current_gtid->uuid, uuid_str,
+ ret = sst_donate_mysqldump(addr, &current_gtid->uuid, uuid_str,
current_gtid->seqno, bypass, env());
}
else
{
- ret = sst_donate_other(method, data, uuid_str,
+ ret = sst_donate_other(method, addr, uuid_str,
current_gtid->seqno, bypass, env());
}