Merge branch '2.2' into develop

This commit is contained in:
Markus Mäkelä 2018-08-30 11:36:58 +03:00
commit a13e95951b
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
47 changed files with 323 additions and 156 deletions

View File

@ -1528,20 +1528,24 @@ This section describes configuration parameters for both servers and listeners
that control the TLS/SSL encryption method and the various certificate files
involved in it.
To enable TLS/SSL for a listener or a server, you must set the `ssl` parameter
to `true` and provide the three files for `ssl_cert`, `ssl_key` and
`ssl_ca_cert`.
To enable TLS/SSL for a listener, you must set the `ssl` parameter to `true`
and provide the three files for `ssl_cert`, `ssl_key` and `ssl_ca_cert`.
To enable TLS/SSL for a server, you must set the `ssl` parameter to `required`
and provide at least the `ssl_ca_cert` parameter. If the backend database server
has certificate verification enabled, the `ssl_cert` and `ssl_key` parameters
must also be defined.
After this, MaxScale connections between the server and/or the client will be
encrypted. Note that the database must be configured to use TLS/SSL connections
if backend connection encryption is used.
encrypted. Note that the database must also be configured to use TLS/SSL
connections if backend connection encryption is used.
**Note:** MaxScale does not allow mixed use of TLS/SSL and normal connections on
the same port.
If TLS encryption is enabled for a listener, any unencrypted connections to it
will be rejected. MaxScale does this to improve security by preventing
accidental creation on unencrypted connections.
accidental creation of unencrypted connections.
The separation of secure and insecure connections differs from the MariaDB
server which allows both secure and insecure connections on the same port. As
@ -1556,7 +1560,7 @@ value and is disabled by default. The parameter also accepts the special values
`required` and `disabled` which were the only supported values before MaxScale
2.3.0.
If enabled, the three certificate files mentioned below must also be
If enabled, the certificate files mentioned above must also be
supplied. MaxScale connections to will then be encrypted with TLS/SSL.
#### `ssl_key`
@ -1578,10 +1582,14 @@ A string giving a file path that identifies an existing readable file. The file
must be the Certificate Authority (CA) certificate for the CA that signed the
certificate referred to in the previous parameter. It will be used to verify
that the certificate is valid. This is a required parameter for both listeners
and servers.
and servers. The CA certificate can consist of a certificate chain.
#### `ssl_version`
**Note:** It is highly recommended to leave this parameter to the default value
of _MAX_. This will guarantee that the strongest available encryption is used.
**Do not change this unless you know what you are doing**.
This parameter controls the level of encryption used. Accepted values are:
* TLSv10
@ -1590,16 +1598,13 @@ This parameter controls the level of encryption used. Accepted values are:
* MAX
The default is to use the highest level of encryption available. For OpenSSL 1.0
and newer this is TLSv1.2. Older versions use TLSv1.0 as the default transport
layer encryption.
**Note:** It is highly recommended to leave this parameter to the default value
of _MAX_. This will guarantee that the strongest available encryption is used.
and newer this is TLSv1.2.
#### `ssl_cert_verify_depth`
The maximum length of the certificate authority chain that will be accepted. The
default value is 9. If changed, the new value must be larger than zero.
default value is 9, same as the OpenSSL default. The configured value must be
larger than 0.
#### `ssl_verify_peer_certificate`
@ -1607,9 +1612,9 @@ Peer certificate verification. This functionality is enabled by default.
When this feature is enabled, the certificate sent by the peer is verified
against the configured Certificate Authority. If you are using self-signed
certificates, disable this feature.
certificates, set `ssl_verify_peer_certificate=false`.
**Example SSL enabled server configuration:**
#### Example SSL enabled server configuration
```
[server1]
@ -1621,19 +1626,18 @@ ssl=required
ssl_cert=/usr/local/mariadb/maxscale/ssl/crt.max-client.pem
ssl_key=/usr/local/mariadb/maxscale/ssl/key.max-client.pem
ssl_ca_cert=/usr/local/mariadb/maxscale/ssl/crt.ca.maxscale.pem
```
This example configuration requires all connections to this server to be
encrypted with SSL. The paths to the certificate files and the Certificate
Authority file are also provided.
**Example SSL enabled listener configuration:**
#### Example SSL enabled listener configuration
```
[RW Split Listener]
[RW-Split-Listener]
type=listener
service=RW Split Router
service=RW-Split-Router
protocol=MariaDBClient
port=3306
ssl=required

View File

@ -196,6 +196,7 @@ typedef struct session
GWBUF* buffer; /*< Buffer to deliver to up. */
} response; /*< Shortcircuited response */
session_close_t close_reason; /*< Reason why the session was closed */
bool load_active; /*< Data streaming state (for LOAD DATA LOCAL INFILE) */
} MXS_SESSION;
/**
@ -642,4 +643,14 @@ MXS_DOWNSTREAM router_as_downstream(MXS_SESSION* session);
*/
const char* session_get_close_reason(const MXS_SESSION* session);
static inline void session_set_load_active(MXS_SESSION* session, bool value)
{
session->load_active = value;
}
static inline bool session_is_load_active(const MXS_SESSION* session)
{
return session->load_active;
}
MXS_END_DECLS

View File

@ -48,8 +48,8 @@ int main(int argc, char *argv[])
test.set_timeout(120);
char * output = test.maxscales->ssh_node_output(0,
"maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro",
true, &exit_code);
"maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro",
true, &exit_code);
std::istringstream iss;
iss.str(output);

View File

@ -63,7 +63,7 @@ int main(int argc, char *argv[])
char result[1024];
Test->maxscales->get_maxadmin_param(0, (char *) "show dbusers RW Split Router", (char *) "Incorrect number of arguments:",
result);
result);
Test->tprintf("result %s\n", result);
if (strstr(result, "show dbusers expects 1 argument") == NULL)

View File

@ -18,9 +18,9 @@ bool try_connect(TestConnections& test)
bool rval = false;
if (rwsplit && master && slave &&
execute_query(rwsplit, "SELECT 1") == 0 &&
execute_query(master, "SELECT 1") == 0 &&
execute_query(slave, "SELECT 1") == 0)
execute_query(rwsplit, "SELECT 1") == 0 &&
execute_query(master, "SELECT 1") == 0 &&
execute_query(slave, "SELECT 1") == 0)
{
rval = true;

View File

@ -17,7 +17,7 @@ int create_key(TestConnections *test)
true);
test->maxscales->ssh_node(0, "maxkeys", true);
char *result = test->maxscales->ssh_node_output(0, "sudo test -f /var/lib/maxscale/.secrets && echo SUCCESS",
false, &exit_code);
false, &exit_code);
if (strncmp(result, "SUCCESS", 7) != 0)
{

View File

@ -23,11 +23,11 @@ void get_output(TestConnections& test)
test.tprintf("MaxScale output:");
}
output = test.maxscales->ssh_node_output(0, "cat /var/log/maxscale/maxscale.log && "
"sudo truncate -s 0 /var/log/maxscale/maxscale.log",
true, &ec);
"sudo truncate -s 0 /var/log/maxscale/maxscale.log",
true, &ec);
if (test.verbose)
{
test.tprintf("%s", output);
test.tprintf("%s", output);
}
free(output);
}

View File

@ -51,7 +51,7 @@ int prepare_test_1(TestConnections& test)
{
cout << LINE << endl;
cout << "Part 1: Stopping master and waiting for failover. Check that another server is promoted." <<
endl;
endl;
cout << LINE << endl;
int node0_id = test.repl->get_server_id(0); // Read master id now before shutdown.
test.repl->stop_node(0);
@ -76,7 +76,7 @@ void prepare_test_2(TestConnections& test)
{
cout << LINE << endl;
cout << "Part 2: Disable replication on server 2 and kill master, check that server 3 or 4 is promoted."
<< endl;
<< endl;
cout << LINE << endl;
test.repl->connect();
check(test);
@ -120,8 +120,8 @@ void prepare_test_3(TestConnections& test)
{
cout << LINE << "\n";
cout << "Part 3: Disable log_bin on server 2, making it invalid for promotion. Enable log-slave-updates "
" on servers 2 and 4. Disable log-slave-updates on server 3. Check that server 4 is promoted on"
" master failure." << "\n" << LINE << endl;
" on servers 2 and 4. Disable log-slave-updates on server 3. Check that server 4 is promoted on"
" master failure." << "\n" << LINE << endl;
get_output(test);
test.maxscales->stop_maxscale(0);
test.repl->stop_node(1);

View File

@ -203,7 +203,7 @@ int main(int argc, char *argv[])
elapsedTime += (double) (t2.tv_usec - t1.tv_usec) / 1000000.0;
}
while ((execute_query_silent(Test->maxscales->conn_rwsplit[0], "SELECT * FROM t1") != 0) &&
(elapsedTime < 10));
(elapsedTime < 10));
Test->tprintf("Quries were blocked during %f (using clock_gettime())", elapsedTime);
Test->tprintf("Quries were blocked during %lu (using time())", time(NULL) - start_time_clock);

View File

@ -101,7 +101,7 @@ int main(int argc, char *argv[])
copy_rules(Test, (char *) "rules_syntax_error", rules_dir);
char *output = Test->maxscales->ssh_node_output(0,
"maxadmin call command dbfwfilter rules/reload Database-Firewall", true, &exit_code);
"maxadmin call command dbfwfilter rules/reload Database-Firewall", true, &exit_code);
Test->add_result(strcasestr(output, "Failed") == NULL, "Reloading rules should fail with syntax errors");
Test->check_maxscale_processes(0, 1);

View File

@ -1,4 +1,5 @@
#include "keepalived_func.h"
#include "get_my_ip.h"
char * print_version_string(TestConnections * Test)
{
@ -15,7 +16,8 @@ void configure_keepalived(TestConnections* Test, char * keepalived_file)
int i;
char client_ip[24];
char * last_dot;
Test->get_client_ip(0, client_ip);
//Test->get_client_ip(0, client_ip);
get_my_ip(Test->maxscales->IP[0], client_ip);
last_dot = client_ip;
Test->tprintf("My IP is %s\n", client_ip);
for (i = 0; i < 3; i++)
@ -32,15 +34,15 @@ void configure_keepalived(TestConnections* Test, char * keepalived_file)
for (i = 0; i < Test->maxscales->N; i++)
{
std::string src = std::string(test_dir)
+ "/keepalived_cnf/"
+ std::string(keepalived_file)
+ std::to_string(i + 1)
+ ".conf";
+ "/keepalived_cnf/"
+ std::string(keepalived_file)
+ std::to_string(i + 1)
+ ".conf";
std::string cp_cmd = "cp "
+ std::string(Test->maxscales->access_homedir[i])
+ std::string(keepalived_file)
+ std::to_string(i + 1) + ".conf "
+ " /etc/keepalived/keepalived.conf";
+ std::string(Test->maxscales->access_homedir[i])
+ std::string(keepalived_file)
+ std::to_string(i + 1) + ".conf "
+ " /etc/keepalived/keepalived.conf";
Test->tprintf("%s\n", src.c_str());
Test->tprintf("%s\n", cp_cmd.c_str());
Test->maxscales->ssh_node(i, "yum install -y keepalived", true);

View File

@ -63,7 +63,8 @@ int main(int argc, char *argv[])
print_version_string(Test);
sleep(FAILOVER_WAIT_TIME);sleep(FAILOVER_WAIT_TIME);
sleep(FAILOVER_WAIT_TIME);
sleep(FAILOVER_WAIT_TIME);
// initial state: 000 expected to be active, 001 - passive
passive = check_maxscale_passive(Test, 0);

View File

@ -61,7 +61,7 @@ int main(int argc, char *argv[])
Test->maxscales->ssh_node(0, (char *) "yum install rng-tools -y", true);
Test->maxscales->ssh_node(0, (char *) "rngd -r /dev/urandom -o /dev/random", true);
Test->maxscales->ssh_node(0, (char *)
"yum install -y MariaDB-gssapi-server MariaDB-gssapi-client krb5-server krb5-workstation pam_krb5", true);
"yum install -y MariaDB-gssapi-server MariaDB-gssapi-client krb5-server krb5-workstation pam_krb5", true);
Test->maxscales->ssh_node_f(0, true, (char *)
"yum install -y MariaDB-gssapi-server MariaDB-gssapi-client krb5-server krb5-workstation pam_krb5");

View File

@ -51,7 +51,7 @@ MYSQL* open_conn_db_flags(int port, std::string ip, std::string db, std::string
}
MYSQL* open_conn_db_timeout(int port, std::string ip, std::string db, std::string user, std::string password,
unsigned int timeout, bool ssl)
unsigned int timeout, bool ssl)
{
MYSQL* conn = mysql_init(NULL);
@ -542,7 +542,8 @@ Result get_result(MYSQL* conn, std::string sql)
Row get_row(MYSQL* conn, std::string sql)
{
Result res = get_result(conn, sql);
return res.empty() ? Row{} : res[0];
return res.empty() ? Row{} :
res[0];
}
int get_int_version(std::string version)

View File

@ -77,7 +77,7 @@ MYSQL* open_conn_db_timeout(int port, std::string ip, std::string db, std::strin
* @return MYSQL struct
*/
static MYSQL* open_conn_db(int port, std::string ip, std::string db, std::string user, std::string password,
bool ssl = false)
bool ssl = false)
{
return open_conn_db_flags(port, ip, db, user, password, CLIENT_MULTI_STATEMENTS, ssl);
}

View File

@ -230,9 +230,9 @@ int Mariadb_nodes::find_master()
while ((found == 0) && (i < N))
{
if (find_field(
nodes[i], (char *) "show slave status;",
(char *) "Master_Host", &str[0]
) == 0 )
nodes[i], (char *) "show slave status;",
(char *) "Master_Host", &str[0]
) == 0 )
{
found = 1;
strcpy(master_IP, str);
@ -714,7 +714,7 @@ static bool multi_source_replication(MYSQL *conn, int node)
MYSQL_RES *res;
if (mysql_query(conn, "SHOW ALL SLAVES STATUS") == 0 &&
(res = mysql_store_result(conn)))
(res = mysql_store_result(conn)))
{
if (mysql_num_rows(res) == 1)
{

View File

@ -15,7 +15,7 @@ int main(int argc, char *argv[])
Test->set_timeout(50);
char *user = Test->maxscales->ssh_node_output(0, "ps -FC maxscale|tail -n 1|cut -f 1 -d \" \"", false,
&exit_code);
&exit_code);
char *nl = user ? strchr(user, '\n') : NULL;
if (nl)

View File

@ -22,7 +22,7 @@ Test setup is described in template. Templates are stored in
Own template have to be put to the same directory.
Default environment for tests consists of:
* one VM for Maxscale
* 2 VMs for Maxscales
* 4 VMs for master/slave setup
* 4 VMs for Galera cluster
@ -35,6 +35,7 @@ Template name|Description
---|---
```nogalera``` |only 1 VM for Maxscale and 4 for Master/Slaves|
```twomaxscales``` |2 VMs for Maxscale and 4 for Master/Slaves|
```onemaxscale``` |1 VM for Maxscale, 4 for Master/Slaves and 4 for Galera|
```big``` |1 VM for Maxscale, 8 for Master/Slaves and 4 for Galera|
```big15``` |1 VM for Maxscale, 15 for Master/Slaves and 4 for Galera|

View File

@ -24,9 +24,6 @@ export maxscale_N=`cat "$MDBCI_VM_PATH/$config_name"_network_config | grep maxsc
sed "s/^/export /g" "$MDBCI_VM_PATH/$config_name"_network_config > "$curr_dir"/"$config_name"_network_config_export
source "$curr_dir"/"$config_name"_network_config_export
# IP Of MaxScale machine
export maxscale_IP=$maxscale_network
export maxscale_sshkey=$maxscale_keyfile
# User name and Password for Master/Slave replication setup (should have all PRIVILEGES)
export node_user="skysql"
@ -83,9 +80,16 @@ do
done
done
export maxscale_access_user=$maxscale_whoami
export maxscale_access_user=$maxscale_000_whoami
export maxscale_access_sudo="sudo "
# IP Of MaxScale machine
export maxscale_network=$maxscale_000_network
export maxscale_keyfile=$maxscale_000_keyfile
export maxscale_IP=$maxscale_000_network
export maxscale_sshkey=$maxscale_000_keyfile
# Sysbench directory (should be sysbench >= 0.5)
export sysbench_dir=${sysbench_dir:-"$HOME/sysbench_deb7/sysbench/"}

View File

@ -104,11 +104,23 @@
}
},
"maxscale" :
"maxscale_000" :
{
"hostname" : "maxscale",
"box" : "${box}",
"memory_size" : "${vm_memory}",
"product" : {
"name" : "maxscale_ci",
"version" : "${target}"
}
},
"maxscale_001" :
{
"hostname" : "maxscale2",
"box" : "${box}",
"memory_size" : "${vm_memory}",
"product" : {
"name" : "maxscale_ci",
"version" : "${target}"

View File

@ -0,0 +1,118 @@
{
"node_000" :
{
"hostname" : "node000",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "${product}",
"version": "${version}",
"cnf_template" : "server1.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"node_001" :
{
"hostname" : "node001",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "${product}",
"version": "${version}",
"cnf_template" : "server2.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"node_002" :
{
"hostname" : "node002",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "${product}",
"version": "${version}",
"cnf_template" : "server3.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"node_003" :
{
"hostname" : "node003",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "${product}",
"version": "${version}",
"cnf_template" : "server4.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"galera_000" :
{
"hostname" : "galera000",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "galera",
"version": "${galera_version}",
"cnf_template" : "galera_server1.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"galera_001" :
{
"hostname" : "galera001",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "galera",
"version": "${galera_version}",
"cnf_template" : "galera_server2.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"galera_002" :
{
"hostname" : "galera002",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "galera",
"version": "${galera_version}",
"cnf_template" : "galera_server3.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"galera_003" :
{
"hostname" : "galera003",
"box" : "${backend_box}",
"memory_size" : "${vm_memory}",
"product" : {
"name": "galera",
"version": "${galera_version}",
"cnf_template" : "galera_server4.cnf",
"cnf_template_path": "${cnf_path}"
}
},
"maxscale" :
{
"hostname" : "maxscale",
"box" : "${box}",
"memory_size" : "${vm_memory}",
"product" : {
"name" : "maxscale_ci",
"version" : "${target}"
}
}
}

View File

@ -27,10 +27,10 @@ int main(int argc, char *argv[])
Test->maxscales->copy_to_node_legacy(cache_rules.c_str(), "~/", 0);
Test->maxscales->ssh_node_f(0, true, "cd %s;"
"rm -rf rules;"
"mkdir rules;"
"chown vagrant:vagrant rules",
Test->maxscales->access_homedir[0]);
"rm -rf rules;"
"mkdir rules;"
"chown vagrant:vagrant rules",
Test->maxscales->access_homedir[0]);
copy_rules(Test, "rules2", fw_rules.c_str());
Test->maxscales->start_maxscale(0);

View File

@ -23,11 +23,11 @@ int main(int argc, char** argv)
// Wait for the data to be processed
const char* logmsg = "Waiting until more data is written";
test.maxscales->ssh_node_f(0, true,
"for ((i=0;i<15;i++)); do grep '%s' /var/log/maxscale/maxscale.log && break || sleep 1; done", logmsg);
"for ((i=0;i<15;i++)); do grep '%s' /var/log/maxscale/maxscale.log && break || sleep 1; done", logmsg);
// Check if the Avro file contains the inserted value
int rc = test.maxscales->ssh_node_f(0, true,
"maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro|grep 'Hello World'");
"maxavrocheck -d /var/lib/maxscale/avro/test.t1.000001.avro|grep 'Hello World'");
test.add_result(rc == 0, "Data is converted when a failure to convert is expected");
printf("\n"

View File

@ -36,22 +36,22 @@ int main(int argc, char** argv)
test.tprintf("Trying query that matches one 'user' row, expecting failure\n");
test.set_timeout(30);
test.add_result(!execute_query(test.maxscales->conn_rwsplit[0], "select concat(a) from t"),
"Query that matches one 'user' row should fail.\n");
"Query that matches one 'user' row should fail.\n");
test.tprintf("Trying query that matches other 'user' row, expecting failure\n");
test.set_timeout(30);
test.add_result(!execute_query(test.maxscales->conn_rwsplit[0], "select concat(b) from t"),
"Query that matches other 'user' row should fail.\n");
"Query that matches other 'user' row should fail.\n");
test.tprintf("Trying query that matches both 'user' rows, expecting failure\n");
test.set_timeout(30);
test.add_result(!execute_query_silent(test.maxscales->conn_rwsplit[0], "select concat(a), concat(b) from t"),
"Query that matches both 'user' rows should fail.\n");
"Query that matches both 'user' rows should fail.\n");
test.tprintf("Trying non-matching query to blacklisted RWSplit, expecting success\n");
test.set_timeout(30);
test.add_result(execute_query_silent(test.maxscales->conn_rwsplit[0], "show status"),
"Non-matching query to blacklist service should succeed.\n");
"Non-matching query to blacklist service should succeed.\n");
test.stop_timeout();
test.tprintf("Checking if MaxScale is alive\n");

View File

@ -21,7 +21,7 @@ void* query_thr(void* data)
while (running)
{
if (mysql_query(mysql, "INSERT INTO test.mxs1585 VALUES (1)") ||
mysql_query(mysql, "DELETE FROM test.mxs1585 LIMIT 100"))
mysql_query(mysql, "DELETE FROM test.mxs1585 LIMIT 100"))
{
break;
}

View File

@ -19,9 +19,11 @@ int main(int argc, char *argv[])
std::vector<uint8_t> wbuf;
auto it = std::back_inserter(wbuf);
for (auto a: {(uint8_t)(caps), (uint8_t)(caps >> 8), (uint8_t)(caps >> 16), (uint8_t)(caps >> 24),
for (auto a: {
(uint8_t)(caps), (uint8_t)(caps >> 8), (uint8_t)(caps >> 16), (uint8_t)(caps >> 24),
(uint8_t)(max_packet), (uint8_t)(max_packet >> 8), (uint8_t)(max_packet >> 16), (uint8_t)(max_packet >> 24),
charset})
charset
})
{
*it++ = a;
}

View File

@ -35,7 +35,7 @@ int main(int argc, char** argv)
MYSQL* conn = open_conn_db(test.maxscales->port(), test.maxscales->ip(), db,
test.maxscales->user_name, test.maxscales->password);
if (execute_query_silent(conn, "SELECT 1") ||
execute_query_silent(conn, "SHOW DATABASES"))
execute_query_silent(conn, "SHOW DATABASES"))
{
errors.insert(mysql_error(conn));
}

View File

@ -87,7 +87,7 @@ int main(int argc, char* argv[])
bool rval = true;
if (mysql_stmt_execute(stmt) ||
mysql_stmt_bind_result(stmt, &bind.bind))
mysql_stmt_bind_result(stmt, &bind.bind))
{
rval = false;
}
@ -107,10 +107,10 @@ int main(int argc, char* argv[])
bool rval = true;
if (mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt))
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt))
{
rval = false;
}
@ -125,10 +125,10 @@ int main(int argc, char* argv[])
bool rval = true;
if (mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_bind_result(stmt, &bind.bind))
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_bind_result(stmt, &bind.bind))
{
rval = false;
}
@ -148,10 +148,10 @@ int main(int argc, char* argv[])
bool rval = true;
if (mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_bind_result(stmt, &bind.bind))
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_bind_result(stmt, &bind.bind))
{
rval = false;
}
@ -171,11 +171,11 @@ int main(int argc, char* argv[])
bool rval = true;
if (mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_query(conn, "SET @a = 1"))
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_stmt_execute(stmt) ||
mysql_query(conn, "SET @a = 1"))
{
rval = false;
}

View File

@ -12,7 +12,9 @@ void checkpoint(TestConnections& test)
const int v = 5;
test.maxscales->wait_for_monitor(v);
for (auto&& s: {"server1", "server2", "server3"})
for (auto&& s: {
"server1", "server2", "server3"
})
{
auto status = test.get_server_status(s);
cout << s << " { ";

View File

@ -31,7 +31,7 @@ void add_remove_maxadmin_user(TestConnections* Test)
Test->tprintf("enable account %s to maxadmin:\n", Test->maxscales->access_user[0]);
char * st3 = Test->maxscales->ssh_node_output_f(0, true, &exit_code, "maxadmin enable account %s",
Test->maxscales->access_user[0]);
Test->maxscales->access_user[0]);
Test->tprintf("Result: %s\n", st3);
sprintf(str, user_added, Test->maxscales->access_user[0]);
if (strstr(st3, str) == NULL)
@ -85,7 +85,7 @@ void add_remove_maxadmin_user(TestConnections* Test)
Test->tprintf("trying to remove user '%s'\n", Test->maxscales->access_user[0]);
char * st8 = Test->maxscales->ssh_node_output_f(0, false, &exit_code, "maxadmin disable account %s",
Test->maxscales->access_user[0]);
Test->maxscales->access_user[0]);
if (strstr(st8, remove_last_admin))
{
@ -138,8 +138,8 @@ int main(int argc, char *argv[])
Test->tprintf("trying long wierd user\n");
Test->maxscales->ssh_node_output(0,
"maxadmin enable account yygrgtrпрекури6н33имн756ККККЕН:УИГГГГ*?:*:*fj34oru34h275g23457g2v90590+u764gv56837fbv62381§SDFERGtrg45ergfergergefewfergt456ty",
true, &exit_code);
"maxadmin enable account yygrgtrпрекури6н33имн756ККККЕН:УИГГГГ*?:*:*fj34oru34h275g23457g2v90590+u764gv56837fbv62381§SDFERGtrg45ergfergergefewfergt456ty",
true, &exit_code);
Test->check_maxscale_alive(0);
Test->maxscales->ssh_node_f(0, true, "rm -rf /var/lib/maxscale/passwd");

View File

@ -25,7 +25,8 @@ int main(int argc, char** argv)
"CREATE USER 'test2'@'%' IDENTIFIED BY 'test2'",
"GRANT dba TO 'test'@'%'",
"GRANT dba TO 'test2'@'%'",
"SET DEFAULT ROLE dba FOR 'test'@'%'"}))
"SET DEFAULT ROLE dba FOR 'test'@'%'"
}))
{
test.try_query(test.repl->nodes[0], "%s", a.c_str());
}
@ -50,7 +51,8 @@ int main(int argc, char** argv)
for (auto a : vector<string>({"DROP DATABASE IF EXISTS my_db",
"DROP ROLE IF EXISTS dba",
"DROP USER 'test'@'%'",
"DROP USER 'test2'@'%'"}))
"DROP USER 'test2'@'%'"
}))
{
execute_query_silent(test.repl->nodes[0], "%s", a.c_str());
}

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
int queried_id = atoi(server_id);
test.add_result(queried_id != real_id, "The query server ID '%d' does not match the one from server '%d'. "
"Slave was not recovered.", queried_id, real_id);
"Slave was not recovered.", queried_id, real_id);
char userval[200] = "";
find_field(test.maxscales->conn_rwsplit[0], "SELECT @a", "@a", userval);

View File

@ -33,12 +33,12 @@ void replicate_from(TestConnections& test, int server_ind, int target_ind)
{
stringstream change_master;
change_master << "CHANGE MASTER TO MASTER_HOST = '" << test.repl->IP[target_ind]
<< "', MASTER_PORT = " << test.repl->port[target_ind] << ", MASTER_USE_GTID = current_pos, "
"MASTER_USER='repl', MASTER_PASSWORD='repl';";
<< "', MASTER_PORT = " << test.repl->port[target_ind] << ", MASTER_USE_GTID = current_pos, "
"MASTER_USER='repl', MASTER_PASSWORD='repl';";
cout << "Server " << server_ind + 1 << " starting to replicate from server " << target_ind + 1 << endl;
if (test.verbose)
{
cout << "Query is '" << change_master.str() << "'" << endl;
cout << "Query is '" << change_master.str() << "'" << endl;
}
test.try_query(test.repl->nodes[server_ind], "STOP SLAVE;");
test.try_query(test.repl->nodes[server_ind], "%s", change_master.str().c_str());
@ -65,7 +65,7 @@ void restore_servers(TestConnections& test, bool events_added)
replicate_from(test, 2, 3);
test.maxscales->wait_for_monitor();
o1 = test.maxscales->ssh_node_output(0,
"maxadmin call command mariadbmon switchover MySQL-Monitor server1 server4", true, &dummy);
"maxadmin call command mariadbmon switchover MySQL-Monitor server1 server4", true, &dummy);
test.maxscales->wait_for_monitor();
int master_id = get_master_server_id(test);
test.assert(master_id == 1, "Switchover failed to set server1 as master.");
@ -116,8 +116,8 @@ int main(int argc, char *argv[])
if (test.global_result != 0)
{
restore_servers(test, false);
return test.global_result;
restore_servers(test, false);
return test.global_result;
}
test.maxscales->connect_maxscale(0);
@ -158,8 +158,8 @@ int main(int argc, char *argv[])
check_maxscale(test);
if (test.global_result == 0)
{
cout << "Test successful, restoring original state." << endl;
restore_servers(test, true);
cout << "Test successful, restoring original state." << endl;
restore_servers(test, true);
}
return test.global_result;
}

View File

@ -63,8 +63,8 @@ int main(int argc, char** argv)
for (int i = FIRST_MOD_NODE; i < NODE_COUNT; i++)
{
if (mysql_query(nodes[i], STOP_SLAVE) != 0 ||
mysql_query(nodes[i], RESET_SLAVE) != 0 ||
mysql_query(nodes[i], READ_ONLY_OFF) != 0)
mysql_query(nodes[i], RESET_SLAVE) != 0 ||
mysql_query(nodes[i], READ_ONLY_OFF) != 0)
{
test.assert(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
return test.global_result;
@ -114,7 +114,7 @@ int main(int argc, char** argv)
// Finally, fix replication by telling the current master to replicate from server4
test.tprintf("Setting server 1 to replicate from server 4. Auto-rejoin should redirect servers 2 and 3.");
const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, "
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
char cmd[256];
snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[3], test.repl->port[3]);
mysql_query(nodes[0], cmd);
@ -125,13 +125,13 @@ int main(int argc, char** argv)
test.assert(master_id == 4, "Server 4 should be the cluster master.");
StringSet node0_states = test.get_server_status("server1");
bool states_n0_ok = (node0_states.find("Slave") != node0_states.end() &&
node0_states.find("Relay Master") == node0_states.end());
node0_states.find("Relay Master") == node0_states.end());
test.assert(states_n0_ok, "Server 1 is not a slave when it should be.");
if (states_n0_ok)
{
int ec;
test.maxscales->ssh_node_output(0,
"maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4" , true, &ec);
"maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4" , true, &ec);
test.maxscales->wait_for_monitor();
master_id = get_master_server_id(test);
test.assert(master_id == 1, "Server 1 should be the cluster master.");

View File

@ -93,7 +93,7 @@ int main(int argc, char** argv)
int master_id_new = get_master_server_id(test);
cout << "Master server id is " << master_id_new << endl;
test.assert(master_id_new > 0 && master_id_new != master_id_old,
"Failover did not promote a new master.");
"Failover did not promote a new master.");
if (test.global_result != 0)
{
return test.global_result;
@ -132,7 +132,7 @@ int main(int argc, char** argv)
cout << "Setting server " << master_id_new << " to replicate from server 1. Server " << master_id_new
<< " should remain as the master because server 1 doesn't have the latest event it has." << endl;
const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, "
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
char cmd[256];
int ind = master_id_new - 1;
snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[0], test.repl->port[0]);

View File

@ -59,8 +59,8 @@ int main(int argc, char** argv)
for (int i = FIRST_MOD_NODE; i < NODE_COUNT; i++)
{
if (mysql_query(nodes[i], STOP_SLAVE) != 0 ||
mysql_query(nodes[i], RESET_SLAVE) != 0 ||
mysql_query(nodes[i], READ_ONLY_OFF) != 0)
mysql_query(nodes[i], RESET_SLAVE) != 0 ||
mysql_query(nodes[i], READ_ONLY_OFF) != 0)
{
test.assert(false, "Could not stop slave connections and/or disable read_only for node %d.", i);
return test.global_result;
@ -110,7 +110,7 @@ int main(int argc, char** argv)
// Finally, fix replication by telling the current master to replicate from server4
test.tprintf("Setting server 1 to replicate from server 4. Manually rejoin servers 2 and 3.");
const char CHANGE_CMD_FMT[] = "CHANGE MASTER TO MASTER_HOST = '%s', MASTER_PORT = %d, "
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
"MASTER_USE_GTID = current_pos, MASTER_USER='repl', MASTER_PASSWORD = 'repl';";
char cmd[256];
snprintf(cmd, sizeof(cmd), CHANGE_CMD_FMT, test.repl->IP[3], test.repl->port[3]);
mysql_query(nodes[0], cmd);
@ -125,13 +125,13 @@ int main(int argc, char** argv)
test.assert(master_id == 4, "Server 4 should be the cluster master.");
StringSet node0_states = test.get_server_status("server1");
bool states_n0_ok = (node0_states.find("Slave") != node0_states.end() &&
node0_states.find("Relay Master") == node0_states.end());
node0_states.find("Relay Master") == node0_states.end());
test.assert(states_n0_ok, "Server 1 is not a slave when it should be.");
if (states_n0_ok)
{
int ec;
test.maxscales->ssh_node_output(0,
"maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4" , true, &ec);
"maxadmin call command mysqlmon switchover MySQL-Monitor server1 server4" , true, &ec);
test.maxscales->wait_for_monitor();
master_id = get_master_server_id(test);
test.assert(master_id == 1, "Server 1 should be the cluster master.");

View File

@ -23,7 +23,7 @@ void get_output(TestConnections& test)
test.tprintf("replication-manager output:");
output = test.maxscales->ssh_node_f(0, true,
"cat /var/log/replication-manager.log && sudo truncate -s 0 /var/log/replication-manager.log");
"cat /var/log/replication-manager.log && sudo truncate -s 0 /var/log/replication-manager.log");
test.tprintf("%s", output);
free(output);
}

View File

@ -129,7 +129,10 @@ int main(int argc, char *argv[])
Test->tprintf("Connecting to RWSplit %s\n", Test->maxscales->IP[0]);
Test->maxscales->connect_rwsplit(0);
Test->maxscales->execute_maxadmin_command(0, (char *) "shutdown monitor MySQL-Monitor");
for (i = 0; i < Test->maxscales->N; i++)
{
Test->maxscales->execute_maxadmin_command(i, (char *) "shutdown monitor MySQL-Monitor");
}
get_global_status_allnodes(&selects[0], &inserts[0], Test->repl, silent);

View File

@ -66,7 +66,7 @@ void check_conn_num(TestConnections* Test, int * Nc)
for (int i = 0; i < 4; i++)
{
int conn_num = get_conn_num(Test->galera->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0],
(char *) "test");
(char *) "test");
Test->tprintf("connections to node %d: %u (expected: %u)\n", i, conn_num, Nc[i]);
if ((i < 4) && (Nc[i] != conn_num))
{

View File

@ -39,7 +39,7 @@ int check_lag(int * min_lag)
{
sprintf(ma_cmd, "show server server%d", i + 1);
maxscales->get_maxadmin_param(0, Test->maxscales->IP[0], (char *) "admin", Test->maxscales->maxadmin_password[0], ma_cmd,
(char *) "Slave delay:", result);
(char *) "Slave delay:", result);
sscanf(result, "%d", &res_d);
Test->tprintf("server%d lag: %d\n", i + 1, res_d);
if (i == 1)
@ -181,13 +181,13 @@ void *checks_thread( void *ptr )
for (int i = 0; i < 1000; i++)
{
maxscales->get_maxadmin_param(0, Test->maxscales->IP[0], (char *) "admin", Test->maxscales->maxadmin_password[0],
(char *) "show server server2", (char *) "Slave delay:", result);
(char *) "show server server2", (char *) "Slave delay:", result);
printf("server2: %s\n", result);
maxscales->get_maxadmin_param(0, Test->maxscales->IP[0], (char *) "admin", Test->maxscales->maxadmin_password[0],
(char *) "show server server3", (char *) "Slave delay:", result);
(char *) "show server server3", (char *) "Slave delay:", result);
printf("server3: %s\n", result);
maxscales->get_maxadmin_param(0, Test->maxscales->IP[0], (char *) "admin", Test->maxscales->maxadmin_password[0],
(char *) "show server server4", (char *) "Slave delay:", result);
(char *) "show server server4", (char *) "Slave delay:", result);
printf("server4: %s\n", result);
}
exit_flag = 1;

View File

@ -161,7 +161,7 @@ void test_binlog(TestConnections* Test)
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values");
Test->add_result(execute_query_check_one(Test->repl->nodes[0], (char *) "SELECT * FROM t1 WHERE fl=10",
"111"), "SELECT check failed");
"111"), "SELECT check failed");
Test->tprintf("ROLLBACK");
@ -175,11 +175,11 @@ void test_binlog(TestConnections* Test)
Test->set_timeout(20);
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values");
Test->add_result(execute_query_check_one(Test->repl->nodes[0], (char *) "SELECT * FROM t1 WHERE fl=10",
"112"), "SELECT check failed");
"112"), "SELECT check failed");
Test->tprintf("SELECT * FROM t1 WHERE fl=10, checking inserted values from slave");
Test->add_result(execute_query_check_one(Test->repl->nodes[2], (char *) "SELECT * FROM t1 WHERE fl=10",
"112"), "SELECT check failed");
"112"), "SELECT check failed");
Test->tprintf("DELETE FROM t1 WHERE fl=10");
Test->try_query(Test->repl->nodes[0], (char *) "DELETE FROM t1 WHERE fl=10");
Test->tprintf("Checking t1");
@ -193,11 +193,11 @@ void test_binlog(TestConnections* Test)
Test->tprintf("SELECT, checking inserted values");
Test->add_result(execute_query_check_one(Test->repl->nodes[0], (char *) "SELECT * FROM t1 WHERE fl=10",
"111"), "SELECT check failed");
"111"), "SELECT check failed");
Test->tprintf("SELECT, checking inserted values from slave");
Test->add_result(execute_query_check_one(Test->repl->nodes[2], (char *) "SELECT * FROM t1 WHERE fl=10",
"111"), "SELECT check failed");
"111"), "SELECT check failed");
Test->tprintf("DELETE FROM t1 WHERE fl=10");
Test->try_query(Test->repl->nodes[0], (char *) "DELETE FROM t1 WHERE fl=10");

View File

@ -142,19 +142,19 @@ TestConnections::TestConnections(int argc, char *argv[]):
break;
case 'h':
{
printf("Options:\n");
struct option *o = long_options;
while (o->name)
{
printf("Options:\n");
struct option *o = long_options;
while (o->name)
{
printf("-%c, --%s\n", o->val, o->name);
++o;
}
exit(0);
printf("-%c, --%s\n", o->val, o->name);
++o;
}
break;
exit(0);
}
break;
case 's':
printf("Maxscale won't be started\n");
@ -847,9 +847,9 @@ int TestConnections::prepare_binlog(int m)
tprintf("Master server version '%s'", version_str);
if (*version_str &&
strstr(version_str, "10.0") == NULL &&
strstr(version_str, "10.1") == NULL &&
strstr(version_str, "10.2") == NULL)
strstr(version_str, "10.0") == NULL &&
strstr(version_str, "10.1") == NULL &&
strstr(version_str, "10.2") == NULL)
{
add_result(maxscales->ssh_node_f(m, true,
"sed -i \"s/,mariadb10-compatibility=1//\" %s",
@ -1069,8 +1069,8 @@ bool TestConnections::replicate_from_master(int m)
conn = open_conn_no_db(maxscales->binlog_port[m], maxscales->IP[m], repl->user_name, repl->password, ssl);
if (find_field(repl->nodes[0], "show master status", "File", log_file) ||
repl->set_slave(conn, repl->IP[0], repl->port[0], log_file, log_pos) ||
execute_query(conn, "start slave"))
repl->set_slave(conn, repl->IP[0], repl->port[0], log_file, log_pos) ||
execute_query(conn, "start slave"))
{
rval = false;
}
@ -1326,7 +1326,7 @@ int TestConnections::check_maxscale_processes(int m, int expected)
{
int exit_code;
char* maxscale_num = maxscales->ssh_node_output(m, "ps -C maxscale | grep maxscale | wc -l", false,
&exit_code);
&exit_code);
if ((maxscale_num == NULL) || (exit_code != 0))
{
return -1;

View File

@ -121,6 +121,7 @@ static MXS_SESSION* session_alloc_body(SERVICE* service, DCB* client_dcb,
session->service = service;
memset(&session->head, 0, sizeof(session->head));
memset(&session->tail, 0, sizeof(session->tail));
session->load_active = false;
/*<
* Associate the session to the client DCB and set the reference count on

View File

@ -1629,7 +1629,7 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF
/**
* Update the currently command being executed.
*/
if (!proto->changing_user)
if (!proto->changing_user && !session_is_load_active(session))
{
update_current_command(session->client_dcb, packetbuf);
}
@ -1639,7 +1639,9 @@ static int route_by_statement(MXS_SESSION* session, uint64_t capabilities, GWBUF
mxb_assert(GWBUF_IS_CONTIGUOUS(packetbuf));
SERVICE *service = session->client_dcb->service;
if (rcap_type_required(capabilities, RCAP_TYPE_TRANSACTION_TRACKING) && !service->session_track_trx_state)
if (rcap_type_required(capabilities, RCAP_TYPE_TRANSACTION_TRACKING) &&
!service->session_track_trx_state &&
!session_is_load_active(session))
{
if (session_trx_is_ending(session))
{

View File

@ -4311,9 +4311,8 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
ssl_error = blr_set_master_ssl(router, change_master, error);
if (ssl_error != -1 &&
(!change_master.ssl_cert ||
!change_master.ssl_ca ||
!change_master.ssl_key))
// No CA cert is defined or only one of CERT or KEY is defined
(!change_master.ssl_ca || (bool)change_master.ssl_cert != (bool)change_master.ssl_key))
{
if (change_master.ssl_enabled &&
atoi(change_master.ssl_enabled))
@ -4321,7 +4320,7 @@ int blr_handle_change_master(ROUTER_INSTANCE* router,
snprintf(error,
BINLOG_ERROR_MSG_LEN,
"MASTER_SSL=1 but some required options are missing: "
"check MASTER_SSL_CERT, MASTER_SSL_KEY, MASTER_SSL_CA");
"check that at least MASTER_SSL_CA is defined");
ssl_error = -1;
}
}

View File

@ -1133,6 +1133,7 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, SRWBackend& target, bool
* to which the server responds with an OK or an ERR packet */
mxb_assert(gwbuf_length(querybuf) == 4);
m_qc.set_load_data_state(QueryClassifier::LOAD_DATA_INACTIVE);
session_set_load_active(m_pSession, false);
}
}
}

View File

@ -550,6 +550,7 @@ void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb)
{
// Server requested a local file, go into data streaming mode
m_qc.set_load_data_state(QueryClassifier::LOAD_DATA_ACTIVE);
session_set_load_active(m_pSession, true);
}
if (m_otrx_state == OTRX_ROLLBACK)