Merge branch '2.1' into 2.2
This commit is contained in:
@ -609,6 +609,10 @@ add_test_executable(mxs1653_ps_hang.cpp mxs1653_ps_hang replication LABELS REPL_
|
||||
# https://jira.mariadb.org/browse/MXS-1677
|
||||
add_test_executable(mxs1677_temp_table.cpp mxs1677_temp_table replication LABELS REPL_BACKEND)
|
||||
|
||||
# MXS-1678: Stopping IO thread on relay master causes it to be promoted as master
|
||||
# https://jira.mariadb.org/browse/MXS-1678
|
||||
add_test_executable(mxs1678_relay_master.cpp mxs1678_relay_master replication LABELS REPL_BACKEND)
|
||||
|
||||
# 'namedserverfilter' test
|
||||
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)
|
||||
|
||||
|
86
maxscale-system-test/mxs1678_relay_master.cpp
Normal file
86
maxscale-system-test/mxs1678_relay_master.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* MXS-1678: Stopping IO thread on relay master causes it to be promoted as master
|
||||
*
|
||||
* https://jira.mariadb.org/browse/MXS-1678
|
||||
*/
|
||||
#include "testconnections.h"
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
typedef std::set<std::string> StringSet;
|
||||
|
||||
// Note: This is backported from 2.2 and can be replaced with MaxScales::get_server_status once merged
|
||||
StringSet state(TestConnections& test, const char* name)
|
||||
{
|
||||
StringSet rval;
|
||||
char* res = test.ssh_maxscale_output(true, "maxadmin list servers|grep \'%s\'", name);
|
||||
char* pipe = strrchr(res, '|');
|
||||
|
||||
if (res && pipe)
|
||||
{
|
||||
pipe++;
|
||||
char* tok = strtok(pipe, ",");
|
||||
|
||||
while (tok)
|
||||
{
|
||||
char* p = tok;
|
||||
char *end = strchr(tok, '\n');
|
||||
if (!end)
|
||||
{
|
||||
end = strchr(tok, '\0');
|
||||
}
|
||||
|
||||
// Trim leading whitespace
|
||||
while (p < end && isspace(*p))
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
// Trim trailing whitespace
|
||||
while (end > tok && isspace(*end))
|
||||
{
|
||||
*end-- = '\0';
|
||||
}
|
||||
|
||||
rval.insert(p);
|
||||
tok = strtok(NULL, ",\n");
|
||||
}
|
||||
}
|
||||
|
||||
free(res);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
TestConnections test(argc, argv);
|
||||
test.repl->connect();
|
||||
execute_query(test.repl->nodes[3], "STOP SLAVE");
|
||||
execute_query(test.repl->nodes[3], "CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d",
|
||||
test.repl->IP_private[2], test.repl->port[2]);
|
||||
execute_query(test.repl->nodes[3], "START SLAVE");
|
||||
|
||||
StringSet master = {"Master", "Running"};
|
||||
StringSet slave = {"Slave", "Running"};
|
||||
StringSet relay_master = {"Relay Master", "Slave", "Running"};
|
||||
|
||||
test.tprintf("Checking before stopping IO thread");
|
||||
test.add_result(state(test, "server1") != master, "server1 is not a master");
|
||||
test.add_result(state(test, "server2") != slave, "server2 is not a slave");
|
||||
test.add_result(state(test, "server3") != relay_master, "server3 is not a relay master");
|
||||
test.add_result(state(test, "server4") != slave, "server4 is not a slave");
|
||||
|
||||
execute_query(test.repl->nodes[2], "STOP SLAVE IO_THREAD");
|
||||
sleep(10);
|
||||
|
||||
test.tprintf("Checking after stopping IO thread");
|
||||
test.add_result(state(test, "server1") != master, "server1 is not a master");
|
||||
test.add_result(state(test, "server2") != slave, "server2 is not a slave");
|
||||
test.add_result(state(test, "server3") != relay_master, "server3 is not a relay master");
|
||||
test.add_result(state(test, "server4") != slave, "server4 is not a slave");
|
||||
|
||||
test.repl->fix_replication();
|
||||
return test.global_result;
|
||||
}
|
@ -2087,10 +2087,10 @@ expr(A) ::= expr(X) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).
|
||||
expr(A) ::= expr(X) PLUS|MINUS(OP) expr(Y).
|
||||
{spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
|
||||
%ifdef MAXSCALE
|
||||
expr(A) ::= expr(X) PLUS|MINUS INTERVAL INTEGER id. {
|
||||
expr(A) ::= INTERVAL INTEGER(X) id. {
|
||||
// Here we could check that id is one of MICROSECOND, SECOND, MINUTE
|
||||
// HOUR, DAY, WEEK, etc.
|
||||
A=X;
|
||||
spanExpr(&A, pParse, @X, &X);
|
||||
}
|
||||
%endif
|
||||
expr(A) ::= expr(X) STAR|SLASH|REM(OP) expr(Y).
|
||||
|
@ -1044,6 +1044,11 @@ public:
|
||||
return rv;
|
||||
}
|
||||
|
||||
const std::string& name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void print(ostream& out) const
|
||||
{
|
||||
out << m_name;
|
||||
@ -1166,6 +1171,19 @@ bool operator == (const QcFunctionInfo& lhs, const QcFunctionInfo& rhs)
|
||||
return lhs.eq(rhs);
|
||||
}
|
||||
|
||||
void collect_missing_function_names(const std::set<QcFunctionInfo>& one,
|
||||
const std::set<QcFunctionInfo>& other,
|
||||
std::set<std::string>* pNames)
|
||||
{
|
||||
for (std::set<QcFunctionInfo>::const_iterator i = one.begin(); i != one.end(); ++i)
|
||||
{
|
||||
if (other.count(*i) == 0)
|
||||
{
|
||||
pNames->insert(i->name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool compare_get_function_info(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1,
|
||||
QUERY_CLASSIFIER* pClassifier2, GWBUF* pCopy2)
|
||||
{
|
||||
@ -1199,7 +1217,47 @@ bool compare_get_function_info(QUERY_CLASSIFIER* pClassifier1, GWBUF* pCopy1,
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "ERR: " << f1 << " != " << f2;
|
||||
std::set<std::string> names1;
|
||||
collect_missing_function_names(f1, f2, &names1);
|
||||
|
||||
std::set<std::string> names2;
|
||||
collect_missing_function_names(f2, f1, &names2);
|
||||
|
||||
bool real_error = false;
|
||||
|
||||
// We assume that names1 are from the qc_mysqlembedded and names2 from qc_sqlite.
|
||||
// The embedded parser reports all date_add(), adddate(), date_sub() and subdate()
|
||||
// functions as date_add_interval(). Further, all "DATE + INTERVAL ..." cases become
|
||||
// use of date_add_interval() functions.
|
||||
for (std::set<std::string>::iterator i = names1.begin(); i != names1.end(); ++i)
|
||||
{
|
||||
if (*i == "date_add_interval")
|
||||
{
|
||||
if ((names2.count("date_add") == 0) &&
|
||||
(names2.count("adddate") == 0) &&
|
||||
(names2.count("date_sub") == 0) &&
|
||||
(names2.count("subdate") == 0) &&
|
||||
(names2.count("+") == 0) &&
|
||||
(names2.count("-") == 0))
|
||||
{
|
||||
real_error = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
real_error = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (real_error)
|
||||
{
|
||||
ss << "ERR: " << f1 << " != " << f2;
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << "Ok : " << f1 << " != " << f2;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
report(success, ss.str());
|
||||
|
@ -89,3 +89,11 @@ call p1();
|
||||
call p1(@var);
|
||||
|
||||
create or replace table t (a int);
|
||||
|
||||
# MXS-1688
|
||||
select id from db2.t1 where DATE_SUB("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
|
||||
select id from db2.t1 where SUBDATE("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
|
||||
select id from db2.t1 where DATE_ADD("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
|
||||
select id from db2.t1 where ADDDATE("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";
|
||||
SELECT '2008-12-31 23:59:59' + INTERVAL 1 SECOND;
|
||||
SELECT '2005-01-01' - INTERVAL 1 SECOND;
|
||||
|
@ -629,6 +629,25 @@ static bool check_server_permissions(SERVICE *service, SERVER* server,
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the current user has the SHOW DATABASES privilege
|
||||
if (mxs_mysql_query(mysql, "SELECT show_db_priv FROM mysql.user "
|
||||
"WHERE CONCAT(user, '@', host) = CURRENT_USER()") == 0)
|
||||
{
|
||||
MYSQL_RES* res = mysql_use_result(mysql);
|
||||
if (res)
|
||||
{
|
||||
MYSQL_ROW row = mysql_fetch_row(res);
|
||||
|
||||
if (row && strcasecmp(row[0], "Y") != 0)
|
||||
{
|
||||
MXS_WARNING("[%s] User '%s' is missing the SHOW DATABASES privilege.",
|
||||
service->name, user);
|
||||
}
|
||||
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
return rval;
|
||||
|
@ -1435,7 +1435,7 @@ static bool do_show_slave_status(MYSQL_MONITOR* mon,
|
||||
* root master server.
|
||||
* Please note, there could be no slaves at all if Slave_SQL_Running == 'No'
|
||||
*/
|
||||
if (serv_info->slave_status.slave_io_running && server_version != MYSQL_SERVER_VERSION_51)
|
||||
if (server_version != MYSQL_SERVER_VERSION_51)
|
||||
{
|
||||
/* Get Master_Server_Id */
|
||||
master_server_id = scan_server_id(row[i_master_server_id]);
|
||||
|
@ -548,27 +548,20 @@ static inline bool connection_is_valid(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES*
|
||||
if (SERVER_IS_RUNNING(router_cli_ses->backend->server) &&
|
||||
(router_cli_ses->backend->server->status & inst->bitmask & inst->bitvalue))
|
||||
{
|
||||
if (inst->bitvalue & SERVER_MASTER)
|
||||
if ((inst->bitvalue & SERVER_MASTER) && router_cli_ses->backend->active)
|
||||
{
|
||||
SERVER_REF* master = get_root_master(inst->service->dbref);
|
||||
|
||||
if (master)
|
||||
{
|
||||
/** Check that the master we are connected to and the one we
|
||||
* determined from the replication topology are one and the same */
|
||||
rval = router_cli_ses->backend == get_root_master(inst->service->dbref);
|
||||
}
|
||||
else
|
||||
{
|
||||
/** No master is available but the one we are connected to is
|
||||
* still a master. This most likely means that the servers for
|
||||
* the service have been modified at runtime. */
|
||||
rval = true;
|
||||
}
|
||||
// If we're using an active master server, verify that it is still a master
|
||||
rval = router_cli_ses->backend == get_root_master(inst->service->dbref);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not a master and bitmask check is OK, everything is OK
|
||||
/**
|
||||
* Either we don't use master type servers or the server reference
|
||||
* is deactivated. We let deactivated connection close gracefully
|
||||
* so we simply assume it is OK. This allows a server to be taken
|
||||
* out of use in a manner that won't cause errors to the connected
|
||||
* clients.
|
||||
*/
|
||||
rval = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user