Merge branch '2.2' into develop

This commit is contained in:
Markus Mäkelä
2018-04-03 11:01:06 +03:00
17 changed files with 180 additions and 65 deletions

View File

@ -4,7 +4,7 @@ MDBCI is a tool to manage virtual machines (VM). VM can be described in
the simple JSON format. the simple JSON format.
JSON templates can be found in [BUILD/mdbci/templates](templates) JSON templates can be found in [BUILD/mdbci/templates](templates)
MDBCI_VM_PATH have to be set before executing any MDBCI commands. MDBCI_VM_PATH have to be set before executing any MDBCI commands.
This variable points to the directory to store 'Vagrantfile's This variable points to the directory to store 'Vagrantfile's
for all VMs as well as all additional files (e.g. *network_config) for all VMs as well as all additional files (e.g. *network_config)
@ -18,7 +18,7 @@ Installation instructions: [PREPARATION_FOR_MDBCI](https://github.com/mariadb-co
[BUILD/mdbci/build.sh](build.sh) prepares VM, executes Maxscale build and creates binary RPM or DEB repository. [BUILD/mdbci/build.sh](build.sh) prepares VM, executes Maxscale build and creates binary RPM or DEB repository.
Build options can be defined in the environmental variables. For variables descriptions and default values see Build options can be defined in the environmental variables. For variables descriptions and default values see
comments in the [BUILD/mdbci/build.sh](build.sh) and [BUILD/mdbci/set_build_variables.sh](set_build_variables.sh) comments in the [BUILD/mdbci/build.sh](build.sh) and [BUILD/mdbci/set_build_variables.sh](set_build_variables.sh)
Script does not store build log, please use ```stdout``` and ```stderr``` redirection to store log. Script does not store build log, please use ```stdout``` and ```stderr``` redirection to store log.
@ -37,7 +37,7 @@ By default VM will not stay alive after the build. Please use ```export do_not_d
to prevent VM from being destroyed. In this case VM have to be destroyed manually by ```mdbci destroy``` to prevent VM from being destroyed. In this case VM have to be destroyed manually by ```mdbci destroy```
command. command.
VM will be created in ```$HOME/vms directory```, binary repository will be created the in VM will be created in ```$HOME/vms directory```, binary repository will be created the in
```$HOME/repository/``` directory. ```$HOME/repository/``` directory.
The name of binary repository sub-directory is generated based on source default The name of binary repository sub-directory is generated based on source default
branch name and current date and time. branch name and current date and time.
@ -56,7 +56,7 @@ If this command exits with success ('0') upgrade test reports PASSED.
## Build with AWS VM ## Build with AWS VM
To build using AWS VM it is necessary to configure AWS credentials and install `vagrant-aws` plugin. To build using AWS VM it is necessary to configure AWS credentials and install `vagrant-aws` plugin.
AWS credentials have to be configured in the $HOME/.aws directory as described in the AWS credentials have to be configured in the $HOME/.aws directory as described in the
[AWS CLI documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html) [AWS CLI documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)
## Example of build ## Example of build
@ -71,8 +71,8 @@ export box="ubuntu_xenial_libvirt"
# examples: # examples:
# source="refs/tags/2.1.1" - tag "2.1.1" # source="refs/tags/2.1.1" - tag "2.1.1"
# source="refs/heads/develop" - "develop" branch # source="refs/heads/develop" - "develop" branch
# source="2.1" - can be branch or tag "2.1" # source="2.1" - can be branch or tag "2.1"
# (use refs/tags and refs/heads if there are # (use refs/tags and refs/heads if there are
# both tag "2.1" and branch "2.1") # both tag "2.1" and branch "2.1")
# source="816983691af8fbded1b2b06a8c19e02587a54f32" - commit ID # source="816983691af8fbded1b2b06a8c19e02587a54f32" - commit ID
export source="2.2" export source="2.2"
@ -83,4 +83,3 @@ export target="2.1-2018Jan10"
cd BUILD/mdbci cd BUILD/mdbci
./build.sh ./build.sh
``` ```

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Copyies repo from ${unsorted_repo_dir}/$target/$box to # Copyes repo from ${unsorted_repo_dir}/$target/$box to
dir=`pwd` dir=`pwd`
if [ "$box_type" == "RPM" ] ; then if [ "$box_type" == "RPM" ] ; then

View File

@ -2,7 +2,7 @@
# Creates RPM or DEB repository for biniries from # Creates RPM or DEB repository for biniries from
# $pre_repo_dir/$target/$box, signs it with keys # $pre_repo_dir/$target/$box, signs it with keys
# from ${gpg_keys_path} and puts signed repo to # from ${gpg_keys_path} and puts signed repo to
set -x set -x

View File

@ -41,7 +41,7 @@ if [ $z_res -eq 127 ] && [ $y_res -eq 127 ] ; then
mkdir -p dists/$dist_name/main/binary-i386/ mkdir -p dists/$dist_name/main/binary-i386/
dpkg-scanpackages dists/$dist_name/main/binary-i386/ /dev/null | gzip -9c > dists/$dist_name/main/binary-i386/Packages.gz dpkg-scanpackages dists/$dist_name/main/binary-i386/ /dev/null | gzip -9c > dists/$dist_name/main/binary-i386/Packages.gz
gunzip -c dists/$dist_name/main/binary-i386/Packages.gz > dists/$dist_name/main/binary-i386/Packages gunzip -c dists/$dist_name/main/binary-i386/Packages.gz > dists/$dist_name/main/binary-i386/Packages
# else # else
# echo "Architectures: ppc64el" >> dists/$dist_name/main/$arch/Release # echo "Architectures: ppc64el" >> dists/$dist_name/main/$arch/Release
fi fi
archs=`ls -1 dists/$dist_name/main | sed "s/binary-//" | tr '\n' ' '` archs=`ls -1 dists/$dist_name/main | sed "s/binary-//" | tr '\n' ' '`
@ -55,7 +55,7 @@ if [ $z_res -eq 127 ] && [ $y_res -eq 127 ] ; then
exit 1 exit 1
fi fi
gpg -abs --digest-algo sha256 -o dists/$dist_name/Release.gpg dists/$dist_name/Release gpg -abs --digest-algo sha256 -o dists/$dist_name/Release.gpg dists/$dist_name/Release
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
echo "Package signing failed!" echo "Package signing failed!"
exit 1 exit 1
@ -72,19 +72,19 @@ else
echo "%_signature gpg" >> ~/.rpmmacros echo "%_signature gpg" >> ~/.rpmmacros
echo "%_gpg_name MariaDB Maxscale <maxscale@googlegroups.com>" >> ~/.rpmmacros echo "%_gpg_name MariaDB Maxscale <maxscale@googlegroups.com>" >> ~/.rpmmacros
echo "\r" | setsid rpm --resign $sourcedir/*.rpm echo "\r" | setsid rpm --resign $sourcedir/*.rpm
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
echo "Package signing failed!" echo "Package signing failed!"
exit 1 exit 1
fi fi
cp $sourcedir/* $destdir/ cp $sourcedir/* $destdir/
pushd ${destdir} >/dev/null 2>&1 pushd ${destdir} >/dev/null 2>&1
createrepo -d -s sha . createrepo -d -s sha .
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
echo "Repo creation failed!" echo "Repo creation failed!"
exit 1 exit 1
fi fi
popd >/dev/null 2>&1 popd >/dev/null 2>&1
gpg --output repomd.xml.key --sign $destdir/repodata/repomd.xml gpg --output repomd.xml.key --sign $destdir/repodata/repomd.xml

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Copyies stuff to VM, run build on VM and copies binaries # Copyies stuff to VM, run build on VM and copies binaries
# to $pre_repo_dir/$target/$box # to $pre_repo_dir/$target/$box
set -x set -x
@ -17,7 +17,7 @@ ssh $sshopt "sudo rm -rf $work_dir"
echo "copying stuff to $image machine" echo "copying stuff to $image machine"
ssh $sshopt "mkdir -p $work_dir" ssh $sshopt "mkdir -p $work_dir"
rsync -avz --delete -e "ssh $scpopt" ${script_dir}/../../ $sshuser@$IP:./$work_dir/ rsync -avz --delete -e "ssh $scpopt" ${script_dir}/../../ $sshuser@$IP:./$work_dir/
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Error copying stuff to $box machine" echo "Error copying stuff to $box machine"
exit 2 exit 2

View File

@ -23,7 +23,7 @@ export source=${scm_source}
export source=${source:-"$branch"} export source=${source:-"$branch"}
echo "source=$source" echo "source=$source"
#hack to get rid of Jenkins artifacts #hack to get rid of Jenkins artifacts
export target=`echo $target | tr -cd "[:print:]" | sed "s/?//g" | sed "s/ //g"` export target=`echo $target | tr -cd "[:print:]" | sed "s/?//g" | sed "s/ //g"`
export target=${target:-"$source-$curr_date"} export target=${target:-"$source-$curr_date"}

View File

@ -37,7 +37,7 @@ ${mdbci_dir}/repository-config/generate_all.sh repo.d
${mdbci_dir}/repository-config/maxscale-release.sh $old_target repo.d ${mdbci_dir}/repository-config/maxscale-release.sh $old_target repo.d
# starting VM for build # starting VM for build
${mdbci_dir}/mdbci --override --template $MDBCI_VM_PATH/$name.json --repo-dir $dir/repo.d generate $name ${mdbci_dir}/mdbci --override --template $MDBCI_VM_PATH/$name.json --repo-dir $dir/repo.d generate $name
${mdbci_dir}/mdbci up $name --attempts=1 ${mdbci_dir}/mdbci up $name --attempts=1
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
@ -92,19 +92,25 @@ else
maxscale_start_cmd="sudo ./maxscale_start.sh 2> /dev/null &" maxscale_start_cmd="sudo ./maxscale_start.sh 2> /dev/null &"
fi fi
ssh $sshopt "sudo cp $cnf_file /etc/maxscale.cnf" ssh $sshopt "sudo cp $cnf_file /etc/maxscale.cnf"
ssh $sshopt "$maxscale_start_cmd" & ssh $sshopt "$maxscale_start_cmd" &
pid_to_kill=$! pid_to_kill=$!
sleep 10 for i in {1..10}
do
sleep 5
ssh $sshopt $maxadmin_command
maxadm_exit=$?
if [ $maxadm_exit == 0 ] ; then
break
fi
done
ssh $sshopt $maxadmin_command if [ $maxadm_exit != 0 ] ; then
if [ $? != 0 ] ; then
echo "Maxadmin executing error" echo "Maxadmin executing error"
res=1 res=1
fi fi
maxadmin_out=`ssh $sshopt $maxadmin_command` maxadmin_out=`ssh $sshopt $maxadmin_command`
echo $maxadmin_out | grep "CLI" echo $maxadmin_out | grep "CLI"
if [ $? != 0 ] ; then if [ $? != 0 ] ; then

View File

@ -731,11 +731,16 @@ users_refresh_time=120
How many statements MaxScale should store for each session. This is for How many statements MaxScale should store for each session. This is for
debugging purposes, as in case of problems it is often of value to be able debugging purposes, as in case of problems it is often of value to be able
to find out exactly what statements were sent before a particular to find out exactly what statements were sent before a particular
problem turned up. See also `dump_last_statements` using which the actual problem turned up.
dumping of the statements is enabled.
**Note:** See also `dump_last_statements` using which the actual dumping
of the statements is enabled. Unless both of the parameters are defined,
the statement dumping mechanism doesn't work.
``` ```
retain_last_statements=20 retain_last_statements=20
``` ```
Default is `0`. Default is `0`.
#### `dump_last_statements` #### `dump_last_statements`

View File

@ -158,7 +158,7 @@ public:
/** /**
* @brief Get a pointer to the internal DCB * @brief Get a pointer to the internal DCB
* *
* @return Pointer to internal DCB * @return Pointer to DCB or NULL if not connected
*/ */
inline DCB* dcb() const inline DCB* dcb() const
{ {

View File

@ -636,6 +636,10 @@ add_test_executable(mxs1713_lots_of_databases.cpp mxs1713_lots_of_databases mxs1
# https://jira.mariadb.org/browse/MXS-1731 # https://jira.mariadb.org/browse/MXS-1731
add_test_executable(mxs1731_old_persisted_config.cpp mxs1731_old_persisted_config replication LABELS REPL_BACKEND) add_test_executable(mxs1731_old_persisted_config.cpp mxs1731_old_persisted_config replication LABELS REPL_BACKEND)
# MXS-1751: Maxscale crashes when certain config is in play (with nodes down)
# https://jira.mariadb.org/browse/MXS-1751
add_test_executable(mxs1751_available_when_donor_crash.cpp mxs1751_available_when_donor_crash mxs1751_available_when_donor_crash LABELS GALERA_BACKEND)
# 'namedserverfilter' test # 'namedserverfilter' test
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND) add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)

View File

@ -15,6 +15,7 @@ module=mysqlmon
servers=server1 servers=server1
user=maxskysql user=maxskysql
passwd=skysql passwd=skysql
monitor_interval=1000
[Masking] [Masking]
type=filter type=filter

View File

@ -0,0 +1,53 @@
[maxscale]
threads=###threads###
[Galera Monitor]
type=monitor
module=galeramon
servers=server1,server2,server3
user=maxskysql
passwd=skysql
monitor_interval=100
available_when_donor=true
[RW Split Router]
type=service
router=readwritesplit
servers=server1,server2,server3
user=maxskysql
passwd=skysql
master_accept_reads=true
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default
[server1]
type=server
address=###galera_server_IP_1###
port=###galera_server_port_1###
protocol=MySQLBackend
[server2]
type=server
address=###galera_server_IP_2###
port=###galera_server_port_2###
protocol=MySQLBackend
[server3]
type=server
address=###galera_server_IP_3###
port=###galera_server_port_3###
protocol=MySQLBackend

View File

@ -1,11 +1,11 @@
# Running Maxscale system tests on Virtual Machines with MDBCI # Running Maxscale system tests on Virtual Machines with MDBCI
MDBCI is a tool to manage virtual machines (VMs). MDBCI is a tool to manage virtual machines (VMs).
VMs can be described in the simple JSON format. VMs can be described in the simple JSON format.
JSON templates for test configuration can be found in JSON templates for test configuration can be found in
[maxscale-system-test/mdbci/templates/](templates/) [maxscale-system-test/mdbci/templates/](templates/)
'MDBCI_VM_PATH' have to be set before executing any MDBCI commands. 'MDBCI_VM_PATH' have to be set before executing any MDBCI commands.
This variable points to the directory to store 'Vagrantfile's This variable points to the directory to store 'Vagrantfile's
for all VMs as well as all additional files (e.g. *network_config) for all VMs as well as all additional files (e.g. *network_config)
@ -17,7 +17,7 @@ Installation instructions: [PREPARATION_FOR_MDBCI](https://github.com/mariadb-co
## Basics of test setup ## Basics of test setup
Test setup is described in template. Templates are stored in Test setup is described in template. Templates are stored in
[maxscale-system-test/mdbci/templates/](templates/) [maxscale-system-test/mdbci/templates/](templates/)
Own template have to be put to the same directory. Own template have to be put to the same directory.
@ -44,13 +44,13 @@ Template can contain references to any environmental variables - they all
will be replaced with values before VMs starting will be replaced with values before VMs starting
The [maxscale-system-test/mdbci/run_test.sh](run_test.sh) script The [maxscale-system-test/mdbci/run_test.sh](run_test.sh) script
brings test VMs configuration up and tries to execute brings test VMs configuration up and tries to execute
```maxscale-system-test``` using 'ctest'. ```maxscale-system-test``` using 'ctest'.
Script can be executed without any parameters and without defining any Script can be executed without any parameters and without defining any
environmental variables. environmental variables.
In this case, tests will be executed for CentOS 7, MariaDB 10.2 and In this case, tests will be executed for CentOS 7, MariaDB 10.2 and
Maxscale from current 'develop' repository Maxscale from current 'develop' repository
[http://max-tst-01.mariadb.com/ci-repository/develop/mariadb-maxscale/](http://max-tst-01.mariadb.com/ci-repository/develop/mariadb-maxscale/) [http://max-tst-01.mariadb.com/ci-repository/develop/mariadb-maxscale/](http://max-tst-01.mariadb.com/ci-repository/develop/mariadb-maxscale/)
VMs will not be destroyed after the tests. VMs will not be destroyed after the tests.
@ -73,7 +73,7 @@ Variable name|Meaning
```name```|The name of test run - any string to identify VMs set| ```name```|The name of test run - any string to identify VMs set|
For complete list of environmental variables see comments in For complete list of environmental variables see comments in
[maxscale-system-test/mdbci/run_test.sh](run_test.sh) [maxscale-system-test/mdbci/run_test.sh](run_test.sh)
and file [maxscale-system-test/mdbci/set_run_test_variables.sh](set_run_test_variables.sh) and file [maxscale-system-test/mdbci/set_run_test_variables.sh](set_run_test_variables.sh)
@ -92,7 +92,7 @@ test_set|Meaning
If ```galera_version``` is not defined the value of ```version``` is used also for Galera backend If ```galera_version``` is not defined the value of ```version``` is used also for Galera backend
### Test execution ### Test execution
After execution of 'run_test.sh` by default VMs stay alive and other tests can be executed. After execution of 'run_test.sh` by default VMs stay alive and other tests can be executed.
@ -100,7 +100,7 @@ Test use environmental variables to get all infio about test setup (about VMs).
The script [maxscale-system-test/mdbci/set_env.sh](set_env.sh) The script [maxscale-system-test/mdbci/set_env.sh](set_env.sh)
loads all needed values (IPs, paths to ssh keyfiles, loads all needed values (IPs, paths to ssh keyfiles,
user names, etc) into environmental variables. Script uses user names, etc) into environmental variables. Script uses
data from ```${MDBCI_VM_PATH}/${name}_network_config``` file data from ```${MDBCI_VM_PATH}/${name}_network_config``` file
and also calls MDBCI commands. and also calls MDBCI commands.
@ -168,7 +168,7 @@ To restore backend separatelly and for intial backend setup check_backend' can b
'run_test.sh' makes snapshot of all VMs before tests. The name of snapshot is 'clean'. 'run_test.sh' makes snapshot of all VMs before tests. The name of snapshot is 'clean'.
In case of problem, after 'snapshot revert' it is recommended to re-create In case of problem, after 'snapshot revert' it is recommended to re-create
${name}_network_config file, re-load environmental variables and run ${name}_network_config file, re-load environmental variables and run
'check_backend' 'check_backend'
```bash ```bash

View File

@ -67,6 +67,9 @@ int main(int argc, char* argv[])
{ {
if (test.maxscales->start() == 0) if (test.maxscales->start() == 0)
{ {
// Give the monitor a few seconds to monitor the servers
sleep(5);
if (test.maxscales->connect_rwsplit() == 0) if (test.maxscales->connect_rwsplit() == 0)
{ {
run(test); run(test);

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2020-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
for (int i = 0; i < 2; i++)
{
test.galera->stop_node(0);
test.galera->stop_node(1);
test.galera->start_node(1);
test.galera->start_node(0);
test.galera->fix_replication();
}
return test.global_result;
}

View File

@ -66,6 +66,7 @@ void Backend::close(close_type type)
} }
dcb_close(m_dcb); dcb_close(m_dcb);
m_dcb = NULL;
/** decrease server current connection counters */ /** decrease server current connection counters */
atomic_add(&m_backend->connections, -1); atomic_add(&m_backend->connections, -1);

View File

@ -260,6 +260,41 @@ static json_t* diagnostics_json(const MXS_MONITOR *mon)
return rval; return rval;
} }
static bool using_xtrabackup(MXS_MONITORED_SERVER *database, const char* server_string)
{
bool rval = false;
MYSQL_RES* result;
if (mxs_mysql_query(database->con, "SHOW VARIABLES LIKE 'wsrep_sst_method'") == 0
&& (result = mysql_store_result(database->con)) != NULL)
{
if (mysql_field_count(database->con) < 2)
{
mysql_free_result(result);
MXS_ERROR("Unexpected result for \"SHOW VARIABLES LIKE "
"'wsrep_sst_method'\". Expected 2 columns."
" MySQL Version: %s", server_string);
}
MYSQL_ROW row;
while ((row = mysql_fetch_row(result)))
{
if (row[1] && strncmp(row[1], "xtrabackup", 10) == 0)
{
rval = true;
}
}
mysql_free_result(result);
}
else
{
mon_report_query_error(database);
}
return rval;
}
/** /**
* Monitor an individual server. Does not deal with the setting of master or * Monitor an individual server. Does not deal with the setting of master or
* slave bits, except for clearing them when a server is not joined to the * slave bits, except for clearing them when a server is not joined to the
@ -273,8 +308,7 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
{ {
GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle; GALERA_MONITOR* handle = (GALERA_MONITOR*) mon->handle;
MYSQL_ROW row; MYSQL_ROW row;
MYSQL_RES *result, *result2; MYSQL_RES *result;
int isjoined = 0;
char *server_string; char *server_string;
/* Don't even probe server flagged as in maintenance */ /* Don't even probe server flagged as in maintenance */
@ -364,6 +398,8 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
info.local_index = local_index; info.local_index = local_index;
} }
ss_dassert(row[0] && row[1]);
if (strcmp(row[0], "wsrep_local_state") == 0) if (strcmp(row[0], "wsrep_local_state") == 0)
{ {
if (strcmp(row[1], "4") == 0) if (strcmp(row[1], "4") == 0)
@ -371,33 +407,10 @@ monitorDatabase(MXS_MONITOR *mon, MXS_MONITORED_SERVER *database)
info.joined = 1; info.joined = 1;
} }
/* Check if the node is a donor and is using xtrabackup, in this case it can stay alive */ /* Check if the node is a donor and is using xtrabackup, in this case it can stay alive */
else if (strcmp(row[1], "2") == 0 && handle->availableWhenDonor == 1) else if (strcmp(row[1], "2") == 0 && handle->availableWhenDonor == 1 &&
using_xtrabackup(database, server_string))
{ {
if (mxs_mysql_query(database->con, "SHOW VARIABLES LIKE 'wsrep_sst_method'") == 0 info.joined = 1;
&& (result2 = mysql_store_result(database->con)) != NULL)
{
if (mysql_field_count(database->con) < 2)
{
mysql_free_result(result);
mysql_free_result(result2);
MXS_ERROR("Unexpected result for \"SHOW VARIABLES LIKE "
"'wsrep_sst_method'\". Expected 2 columns."
" MySQL Version: %s", server_string);
return;
}
while ((row = mysql_fetch_row(result2)))
{
if (strncmp(row[1], "xtrabackup", 10) == 0)
{
info.joined = 1;
}
}
mysql_free_result(result2);
}
else
{
mon_report_query_error(database);
}
} }
else else
{ {