Merge remote-tracking branch 'origin/develop' into MXS-329-develop-20151111

# Conflicts:
#	server/core/CMakeLists.txt
#	server/core/buffer.c
#	server/core/service.c
#	server/modules/filter/tee.c
#	server/modules/monitor/mysql_mon.c
#	server/modules/routing/binlog/blr.c
#	server/modules/routing/binlog/blr_slave.c
#	server/modules/routing/debugcmd.c
#	server/modules/routing/readwritesplit/readwritesplit.c
#	utils/skygw_utils.cc

- resolved.
This commit is contained in:
counterpoint
2015-11-11 11:08:02 +00:00
436 changed files with 289135 additions and 8102 deletions

View File

@ -47,8 +47,6 @@
#include <mysql_client_server_protocol.h>
extern int lm_enabled_logfiles_bitmask;
static char *version_str = "V1.0.0";
/* The router entry points */

View File

@ -23,3 +23,7 @@ add_executable(maxbinlogcheck maxbinlogcheck.c blr_file.c blr_cache.c blr_master
target_link_libraries(maxbinlogcheck utils ssl pthread ${EMBEDDED_LIB} ${PCRE_LINK_FLAGS} aio rt crypt dl crypto inih z m stdc++ ${CURL_LIBRARIES})
install(TARGETS maxbinlogcheck DESTINATION bin)
if(BUILD_TESTS)
add_subdirectory(test)
endif()

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright MariaDB Corporation Ab 2014
* Copyright MariaDB Corporation Ab 2014-2015
*/
/**
@ -53,11 +53,6 @@
#include <log_manager.h>
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
/**
* Initialise the cache for this instanceof the binlog router. As a side
* effect also determine the binlog file to read and the position to read

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,9 +63,6 @@
#include <version.h>
#include <gwdirs.h>
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
extern int blr_read_events_all_events(ROUTER_INSTANCE *router, int fix, int debug);
extern uint32_t extract_field(uint8_t *src, int bits);
static void printVersion(const char *progname);
@ -80,11 +77,17 @@ static struct option long_options[] = {
{0, 0, 0, 0}
};
char *binlog_check_version = "1.0.0";
char *binlog_check_version = "1.1.0";
int
MaxScaleUptime()
{
return 1;
}
int main(int argc, char **argv) {
char** arg_vector;
int arg_count = 4;
int arg_count = 1;
ROUTER_INSTANCE *inst;
int fd;
int ret;
@ -132,11 +135,8 @@ int main(int argc, char **argv) {
}
arg_vector[0] = "logmanager";
arg_vector[1] = "-j";
arg_vector[2] = "/tmp/maxbinlogcheck";
arg_vector[3] = "-o";
arg_vector[4] = NULL;
skygw_logmanager_init(arg_count,arg_vector);
arg_vector[1] = NULL;
skygw_logmanager_init(NULL, arg_count, arg_vector);
skygw_log_set_augmentation(0);

View File

@ -0,0 +1,5 @@
if(BUILD_TESTS)
add_executable(testbinlogrouter testbinlog.c ../blr.c ../blr_slave.c ../blr_master.c ../blr_file.c ../blr_cache.c)
target_link_libraries(testbinlogrouter fullcore ssl pthread log_manager)
add_test(TestBinlogRouter ${CMAKE_CURRENT_BINARY_DIR}/testbinlogrouter)
endif()

View File

@ -0,0 +1,600 @@
/*
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright MariaDB Corporation Ab 2015
*/
/**
* @file testbinlog.c - The MaxScale CHANGE MASTER TO syntax test
*
* Revision History
*
* Date Who Description
* 24/08/2015 Massimiliano Pinto Initial implementation
*
* @endverbatim
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <service.h>
#include <server.h>
#include <router.h>
#include <atomic.h>
#include <spinlock.h>
#include <blr.h>
#include <dcb.h>
#include <spinlock.h>
#include <housekeeper.h>
#include <time.h>
#include <skygw_types.h>
#include <skygw_utils.h>
#include <log_manager.h>
#include <gwdirs.h>
#include <mysql_client_server_protocol.h>
#include <ini.h>
#include <sys/stat.h>
#include <getopt.h>
#include <version.h>
static void printVersion(const char *progname);
static void printUsage(const char *progname);
extern int blr_test_parse_change_master_command(char *input, char *error_string, CHANGE_MASTER_OPTIONS *config);
extern char *blr_test_set_master_logfile(ROUTER_INSTANCE *router, char *filename, char *error);
extern int blr_test_handle_change_master(ROUTER_INSTANCE* router, char *command, char *error);
int
MaxScaleUptime()
{
return 1;
}
static struct option long_options[] = {
{"debug", no_argument, 0, 'd'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"fix", no_argument, 0, 'f'},
{"help", no_argument, 0, '?'},
{0, 0, 0, 0}
};
int main(int argc, char **argv) {
char** arg_vector;
ROUTER_INSTANCE *inst;
int ret;
int rc;
int arg_count = 1;
char error_string[BINLOG_ERROR_MSG_LEN + 1] = "";
CHANGE_MASTER_OPTIONS change_master;
char query[255+1]="";
char saved_query[255+1]="";
int command_offset = strlen("CHANGE MASTER TO");
char *master_log_file = NULL;
char *master_log_pos = NULL;
SERVICE *service;
char *roptions;
int tests = 1;
roptions = strdup("server-id=3,heartbeat=200,binlogdir=/not_exists/my_dir,transaction_safety=1,master_version=5.6.99-common,master_hostname=common_server,master_uuid=xxx-fff-cccc-fff,master-id=999");
arg_vector = malloc(sizeof(char*)*(arg_count + 1));
if(arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation FAILED for log manager arg_vector.\n");
return 1;
}
arg_vector[0] = "logmanager";
arg_vector[1] = NULL;
skygw_logmanager_init(NULL, arg_count,arg_vector);
free(arg_vector);
skygw_log_disable(LOGFILE_DEBUG);
skygw_log_disable(LOGFILE_TRACE);
skygw_log_disable(LOGFILE_ERROR);
skygw_log_disable(LOGFILE_MESSAGE);
service = service_alloc("test_service", "binlogrouter");
service->credentials.name = strdup("foo");
service->credentials.authdata = strdup("bar");
{
char *lasts;
SERVER *server;
char *s = strtok_r(roptions, ",", &lasts);
while (s)
{
serviceAddRouterOption(service, s);
s = strtok_r(NULL, ",", &lasts);
}
server = server_alloc("_none_", "MySQLBackend", (int)3306);
if (server == NULL) {
if (service->users) {
users_free(service->users);
}
return 1;
}
server_set_unique_name(server, "binlog_router_master_host");
serviceAddBackend(service, server);
}
if ((inst = calloc(1, sizeof(ROUTER_INSTANCE))) == NULL) {
LOGIF(LE, (skygw_log_write_flush(LOGFILE_ERROR,
"Error: Memory allocation FAILED for ROUTER_INSTANCE")));
skygw_log_sync_all();
skygw_logmanager_done();
return 1;
}
inst->service = service;
inst->user = service->credentials.name;
inst->password = service->credentials.authdata;
LOGIF(LM, (skygw_log_write_flush(LOGFILE_MESSAGE, "testbinlog v1.0")));
if (inst->fileroot == NULL)
inst->fileroot = strdup(BINLOG_NAME_ROOT);
if (!inst->current_pos)
inst->current_pos = 4;
/********************************************
*
* First test suite is about syntax parsing
*
********************************************/
printf("--------- CHANGE MASTER TO parsing tests ---------\n");
/**
* Test 1: no given options
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO" + command_offset);
/* Expected rc is 1, if 0 test fails */
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: no options for [%s] FAILED\n", tests, query);
return 1;
} else printf("Test %d PASSED, no given options for [%s]\n", tests, query);
tests++;
/**
* Test 2: 1 wrong option without value
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO X" + command_offset);
/* Expected rc is 1, if 0 test fails */
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, query);
tests++;
/**
* Test 3: 1 wrong option with missing value after =
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO X=" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 4: 1 wrong option with missing value after =
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO X =" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 5: 1 wrong option with missing value after =
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO X= " + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 6: 1 wrong option with missing value after =
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO X = " + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 7: 1 valid option with missing value
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 8: 1 valid option with missing value
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = " + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: wrong options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, wrong options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 9: 1 valid option with value
*
* Expected rc is 0, if 1 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1'" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 1) {
printf("Test %d: valid option for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 10: 1 valid option and 2 invalid ones
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', Y, X" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: valid / not valid options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid / not valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 11: 1 valid option and 1 with missing value
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: valid / not valid options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid / not valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 12: 2 valid options
*
* Expected rc is 0, if 1 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 1) {
printf("Test %d: valid options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 13: 2 valid options and 1 invalid
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWD='massi'" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: valid / not valid options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid / not valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 14: 3 valid options
*
* Expected rc is 0, if 1 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi'" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 1) {
printf("Test %d: valid options [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 15: 5 valid options and 1 invalid
*
* Expected rc is 1, if 0 test fails
*/
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi', MAster_user='eee', master_log_fil= 'fffff', master_log_pos= 55" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 0) {
printf("Test %d: valid / not valid options for [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid / not valid options for [%s]\n", tests, saved_query);
tests++;
/**
* Test 16: 6 valid options
*
* Expected rc is 0, if 1 test fails
*/
strcpy(error_string, "");
memset(&change_master, 0, sizeof(change_master));
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi', MAster_user='eee', master_log_file= 'fffff', master_log_pos= 55" + command_offset);
strcpy(saved_query, query);
rc = blr_test_parse_change_master_command(query, error_string, &change_master);
if (rc == 1) {
printf("Test %d: valid options [%s] FAILED\n", tests, saved_query);
return 1;
} else printf("Test %d PASSED, valid options for [%s]\n", tests, saved_query);
tests++;
printf("--------- MASTER_LOG_FILE tests ---------\n");
/**
* Test 17: use current binlog filename in master_state != BLRM_UNCONFIGURED
* and try to set a new filename with wront format from previous test
*
* Expected master_log_file is NULL and error_string is not empty
*/
inst->master_state = BLRM_SLAVE_STOPPED;
strcpy(error_string, "");
master_log_file = blr_test_set_master_logfile(inst, change_master.binlog_file, error_string);
if (master_log_file == NULL) {
if (strlen(error_string)) {
printf("Test %d PASSED, MASTER_LOG_FILE [%s]: [%s]\n", tests, change_master.binlog_file, error_string);
} else {
printf("Test %d: set MASTER_LOG_FILE [%s] FAILED, an error message was expected\n", tests, change_master.binlog_file);
return 1;
}
} else {
printf("Test %d: set MASTER_LOG_FILE [%s] FAILED, NULL was expected from blr_test_set_master_logfile()\n", tests, change_master.binlog_file);
return 1;
}
tests++;
printf("--- MASTER_LOG_POS and MASTER_LOG_FILE rule/constraints checks ---\n");
/********************************************
*
* Second part of test suite is for checking
* rules and constraints once syntax is OK
*
********************************************/
/**
* Test 18: change master without MASTER_LOG_FILE in BLRM_UNCONFIGURED state
*
* Expected rc = -1 and master_state still set to BLRM_UNCONFIGURED
*/
inst->master_state = BLRM_UNCONFIGURED;
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi', MAster_user='eee', master_log_pos= 55");
rc = blr_test_handle_change_master(inst, query, error_string);
if (rc == -1 && inst->master_state == BLRM_UNCONFIGURED) {
printf("Test %d PASSED, in BLRM_UNCONFIGURED state. Message [%s]\n", tests, error_string);
} else {
printf("Test %d: an error message was expected from blr_test_handle_change_master(), Master State is %s. Message [%s]\n", tests, blrm_states[inst->master_state], error_string);
return 1;
}
tests++;
/**
* Test 19: use selected binlog filename in BLRM_UNCONFIGURED state
*
* Expected rc = -1 and master_state still set to BLRM_UNCONFIGURED
*/
inst->master_state = BLRM_UNCONFIGURED;
strcpy(error_string, "");
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi', MAster_user='eee', master_log_file= 'file.000053', master_log_pos= 1855");
rc = blr_test_handle_change_master(inst, query, error_string);
if (rc == -1 && inst->master_state == BLRM_UNCONFIGURED) {
printf("Test %d PASSED, cannot set MASTER_LOG_FILE in BLRM_UNCONFIGURED state for [%s]. Message [%s]\n", tests, query, error_string);
} else {
printf("Test %d: set MASTER_LOG_FILE in BLRM_UNCONFIGURED state FAILED, an error message was expected from blr_test_handle_change_master(), Master State is %s. Message [%s]\n", tests, blrm_states[inst->master_state], error_string);
return 1;
}
tests++;
/**
* Test 20: use selected binlog filename and pos in state != BLRM_UNCONFIGURED
* Current binlog and pos are same specified in the change master command
*
* Expected rc = 0
*/
inst->master_state = BLRM_UNCONNECTED;
strcpy(error_string, "");
strncpy(inst->binlog_name, "file-bin.00008", BINLOG_FNAMELEN);
inst->current_pos = 55;
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi', MAster_user='eee', master_log_file= 'file-bin.00008', master_log_pos= 55");
rc = blr_test_handle_change_master(inst, query, error_string);
if (rc == 0) {
printf("Test %d PASSED, set MASTER_LOG_FILE and MASTER_LOG_POS for [%s]\n", tests, query);
} else {
printf("Test %d: set MASTER_LOG_FILE and MASTER_LOG_POS FAILED, Master State is %s. Message [%s]\n", tests, blrm_states[inst->master_state], error_string);
return 1;
}
tests++;
/**
* Test 21: use selected binlog filename and pos in state != BLRM_UNCONFIGURED
* Current binlog is not the one specified in the change master command
*
* Expected rc = -1
*/
strncpy(inst->binlog_name, "file.000006", BINLOG_FNAMELEN);
inst->current_pos = 10348;
strcpy(inst->fileroot, "file");
strcpy(error_string, "");
inst->master_state = BLRM_UNCONNECTED;
strcpy(query, "CHANGE MASTER TO MasTER_hoST = '127.0.0.1', MASTER_PORT=9999, MASTER_PASSWORD='massi', MAster_user='eee', MASTER_LOG_file ='mmmm.098777', master_log_pos= 55");
rc = blr_test_handle_change_master(inst, query, error_string);
if (rc == -1) {
printf("Test %d PASSED, cannot set MASTER_LOG_FILE for [%s], Message [%s]\n", tests, query, error_string);
} else {
printf("Test %d: set MASTER_LOG_FILE, Master State is %s Failed, Message [%s]\n", tests, blrm_states[inst->master_state], error_string);
return 1;
}
tests++;
/**
* Test 22: use selected binlog filename is next one in sequence and specified pos is 4
* in any state
*
* Expected rc >= 0
*/
strcpy(error_string, "");
strncpy(inst->binlog_name, "file.100506", BINLOG_FNAMELEN);
inst->current_pos = 1348;
strcpy(inst->fileroot, "file");
strcpy(query, "CHANGE MASTER TO master_log_pos= 4 , master_log_file='file.100507'");
rc = blr_test_handle_change_master(inst, query, error_string);
if (rc >= 0) {
printf("Test %d PASSED, set MASTER_LOG_FILE for [%s]\n", tests, query);
} else {
printf("Test %d: set MASTER_LOG_FILE FAILED, Master State is %s. Message [%s]\n", tests, blrm_states[inst->master_state], error_string);
return 1;
}
tests++;
/**
* Test 23: use selected pos that's not the current one
* in state != BLRM_UNCONFIGURED
*
* Expected rc = -1
*/
inst->master_state = BLRM_UNCONNECTED;
strcpy(error_string, "");
strncpy(inst->binlog_name, "file.100506", BINLOG_FNAMELEN);
inst->current_pos = 138;
strcpy(inst->fileroot, "file");
strcpy(query, "CHANGE MASTER TO master_log_pos= 49 ");
rc = blr_test_handle_change_master(inst, query, error_string);
if (rc == -1) {
printf("Test %d PASSED, cannot set MASTER_LOG_POS for [%s], Message [%s]\n", tests, query, error_string);
} else {
printf("Test %d: set MASTER_LOG_POS FAILED, Master State is %s. Message [%s]\n", tests, blrm_states[inst->master_state], error_string);
return 1;
}
skygw_log_sync_all();
skygw_logmanager_done();
free(inst);
return 0;
}

View File

@ -53,11 +53,6 @@ MODULE_INFO info = {
"The admin user interface"
};
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
static char *version_str = "V1.0.0";
/* The router entry points */

View File

@ -52,11 +52,6 @@ MODULE_INFO info = {
"The debug user interface"
};
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
static char *version_str = "V1.1.1";
/* The router entry points */

File diff suppressed because it is too large Load Diff

View File

@ -64,11 +64,6 @@ MODULE_INFO info = {
"The MaxScale Information Schema"
};
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
extern char *create_hex_sha1_sha1_passwd(char *passwd);
static char *version_str = "V1.0.0";

View File

@ -45,11 +45,6 @@
#include <log_manager.h>
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
/**
* Process a parse error and send error report to client
*

View File

@ -49,10 +49,6 @@
#include <resultset.h>
#include <maxconfig.h>
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
static void exec_show(DCB *dcb, MAXINFO_TREE *tree);
static void exec_select(DCB *dcb, MAXINFO_TREE *tree);
static void exec_show_variables(DCB *dcb, MAXINFO_TREE *filter);

View File

@ -96,11 +96,6 @@
#include "modutil.h"
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
MODULE_INFO info = {
MODULE_API_ROUTER,
MODULE_GA,

View File

@ -47,10 +47,6 @@ MODULE_INFO info = {
#define RWSPLIT_TRACE_MSG_LEN 1000
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
/**
* @file readwritesplit.c The entry points for the read/write query splitting
* router module.
@ -109,6 +105,7 @@ static DCB* rses_get_client_dcb(ROUTER_CLIENT_SES* rses);
static route_target_t get_route_target (
skygw_query_type_t qtype,
bool trx_active,
bool load_active,
target_t use_sql_variables_in,
HINT* hint);
@ -1373,6 +1370,7 @@ static backend_ref_t* check_candidate_bref(
static route_target_t get_route_target (
skygw_query_type_t qtype,
bool trx_active,
bool load_active,
target_t use_sql_variables_in,
HINT* hint)
{
@ -1380,13 +1378,15 @@ static route_target_t get_route_target (
/**
* These queries are not affected by hints
*/
if (QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
if (!load_active && (QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) ||
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT) ||
/** Configured to allow writing variables to all nodes */
(use_sql_variables_in == TYPE_ALL &&
QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE)) ||
/** enable or disable autocommit are always routed to all */
QUERY_IS_TYPE(qtype, QUERY_TYPE_ENABLE_AUTOCOMMIT) ||
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT))
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT)))
{
/**
* This is problematic query because it would be routed to all
@ -1424,7 +1424,7 @@ static route_target_t get_route_target (
/**
* Hints may affect on routing of the following queries
*/
else if (!trx_active &&
else if (!trx_active && !load_active &&
(QUERY_IS_TYPE(qtype, QUERY_TYPE_READ) || /*< any SELECT */
QUERY_IS_TYPE(qtype, QUERY_TYPE_SHOW_TABLES) || /*< 'SHOW TABLES' */
QUERY_IS_TYPE(qtype, QUERY_TYPE_USERVAR_READ)|| /*< read user var */
@ -2148,8 +2148,13 @@ static bool route_single_stmt(
if(packet_len == 0)
{
/** Empty packet signals end of LOAD DATA LOCAL INFILE, send it to master*/
route_target = TARGET_MASTER;
packet_type = MYSQL_COM_UNDEFINED;
rses->rses_load_active = false;
route_target = TARGET_MASTER;
skygw_log_write_flush(LT, "> LOAD DATA LOCAL INFILE finished: "
"%lu bytes sent.", rses->rses_load_data_sent + gwbuf_length(querybuf));
}
else
{
@ -2199,17 +2204,36 @@ static bool route_single_stmt(
break;
} /**< switch by packet type */
/**
* Check if the query has anything to do with temporary tables.
*/
if (!rses_begin_locked_router_action(rses))
{
succp = false;
goto retblock;
}
}
/**
* Check if the query has anything to do with temporary tables.
*/
qtype = is_read_tmp_table(rses, querybuf, qtype);
check_create_tmp_table(rses, querybuf, qtype);
check_drop_tmp_table(rses, querybuf,qtype);
/**
* Check if this is a LOAD DATA LOCAL INFILE query. If so, send all queries
* to the master until the last, empty packet arrives.
*/
if (!rses->rses_load_active)
{
skygw_query_op_t queryop = query_classifier_get_operation(querybuf);
if (queryop == QUERY_OP_LOAD)
{
rses->rses_load_active = true;
rses->rses_load_data_sent = 0;
}
}
else
{
rses->rses_load_data_sent += gwbuf_length(querybuf);
}
rses_end_locked_router_action(rses);
/**
* If autocommit is disabled or transaction is explicitly started
@ -2250,28 +2274,35 @@ static bool route_single_stmt(
if (LOG_IS_ENABLED(LOGFILE_TRACE))
{
uint8_t* packet = GWBUF_DATA(querybuf);
unsigned char ptype = packet[4];
size_t len = MIN(GWBUF_LENGTH(querybuf),
MYSQL_GET_PACKET_LEN((unsigned char *)querybuf->start)-1);
char* data = (char*)&packet[5];
char* contentstr = strndup(data, MIN(len, RWSPLIT_TRACE_MSG_LEN));
char* qtypestr = skygw_get_qtype_str(qtype);
skygw_log_write(
LOGFILE_TRACE,
"> Autocommit: %s, trx is %s, cmd: %s, type: %s, "
"stmt: %s%s %s",
(rses->rses_autocommit_enabled ? "[enabled]" : "[disabled]"),
(rses->rses_transaction_active ? "[open]" : "[not open]"),
STRPACKETTYPE(ptype),
(qtypestr==NULL ? "N/A" : qtypestr),
contentstr,
(querybuf->hint == NULL ? "" : ", Hint:"),
(querybuf->hint == NULL ? "" : STRHINTTYPE(querybuf->hint->type)));
free(contentstr);
free(qtypestr);
if (!rses->rses_load_active)
{
uint8_t* packet = GWBUF_DATA(querybuf);
unsigned char ptype = packet[4];
size_t len = MIN(GWBUF_LENGTH(querybuf),
MYSQL_GET_PACKET_LEN((unsigned char *)querybuf->start) - 1);
char* data = (char*) &packet[5];
char* contentstr = strndup(data, MIN(len, RWSPLIT_TRACE_MSG_LEN));
char* qtypestr = skygw_get_qtype_str(qtype);
skygw_log_write(LOGFILE_TRACE,
"> Autocommit: %s, trx is %s, cmd: %s, type: %s, "
"stmt: %s%s %s",
(rses->rses_autocommit_enabled ? "[enabled]" : "[disabled]"),
(rses->rses_transaction_active ? "[open]" : "[not open]"),
STRPACKETTYPE(ptype),
(qtypestr == NULL ? "N/A" : qtypestr),
contentstr,
(querybuf->hint == NULL ? "" : ", Hint:"),
(querybuf->hint == NULL ? "" : STRHINTTYPE(querybuf->hint->type)));
free(contentstr);
free(qtypestr);
}
else
{
skygw_log_write(LT, "> Processing LOAD DATA LOCAL INFILE: "
"%lu bytes sent.", rses->rses_load_data_sent);
}
}
/**
* Find out where to route the query. Result may not be clear; it is
@ -2292,9 +2323,10 @@ static bool route_single_stmt(
*/
route_target = get_route_target(qtype,
rses->rses_transaction_active,
rses->rses_load_active,
rses->rses_config.rw_use_sql_variables_in,
querybuf->hint);
if (TARGET_IS_ALL(route_target))
{
/** Multiple, conflicting routing target. Return error */
@ -4549,7 +4581,7 @@ static bool route_session_write(
if (router_cli_ses->rses_config.rw_max_sescmd_history_size > 0 &&
router_cli_ses->rses_nsescmd >= router_cli_ses->rses_config.rw_max_sescmd_history_size)
{
skygw_log_write(LE, "Warning: Router session exceeded session command history limit. "
skygw_log_write(LM, "Warning: Router session exceeded session command history limit. "
"Slave recovery is disabled and only slave servers with consistent session state are used "
"for the duration of the session.");
router_cli_ses->rses_config.rw_disable_sescmd_hist = true;

File diff suppressed because it is too large Load Diff

View File

@ -18,11 +18,6 @@
#include <sharding_common.h>
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
/**
* Extract the database name from a COM_INIT_DB or literal USE ... query.
* @param buf Buffer with the database change query
@ -100,17 +95,17 @@ void create_error_reply(char* fail_str,DCB* dcb)
}
/**
* Read new database name from MYSQL_COM_INIT_DB packet or a literal USE ... COM_QUERY packet, check that it exists
* in the hashtable and copy its name to MYSQL_session.
* Read new database name from MYSQL_COM_INIT_DB packet or a literal USE ... COM_QUERY
* packet, check that it exists in the hashtable and copy its name to MYSQL_session.
*
* @param mysql_session The MySQL session structure
* @param dest Destination where the database name will be written
* @param dbhash Hashtable containing valid databases
* @param buf Buffer containing the database change query
*
* @return true if new database is set, false if non-existent database was tried
* to be set
*/
bool change_current_db(MYSQL_session* mysql_session,
bool change_current_db(char* dest,
HASHTABLE* dbhash,
GWBUF* buf)
{
@ -139,7 +134,7 @@ bool change_current_db(MYSQL_session* mysql_session,
}
else
{
strncpy(mysql_session->db,db,MYSQL_DATABASE_MAXLEN);
strcpy(dest,db);
skygw_log_write(LOGFILE_TRACE,"change_current_db: database is on server: '%s'.",target);
succp = true;
goto retblock;

View File

@ -46,10 +46,6 @@ MODULE_INFO info = {
};
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
extern size_t log_ses_count[];
extern __thread log_info_t tls_log_info;
/**
* @file shardrouter.c
*
@ -1699,7 +1695,7 @@ routeQuery(ROUTER* instance,
if(packet_type == MYSQL_COM_INIT_DB)
{
if(!(change_successful = change_current_db(router_cli_ses->rses_mysql_session,
if(!(change_successful = change_current_db(router_cli_ses->current_db,
router_cli_ses->dbhash,
querybuf)))
{
@ -2472,23 +2468,6 @@ execute_sescmd_in_backend(SUBSERVICE* subsvc)
rc = SESSION_ROUTE_QUERY(subsvc->session,sescmd_cursor_clone_querybuf(scur));
break;
case MYSQL_COM_INIT_DB:
{
/**
* Record database name and store to session.
*/
GWBUF* tmpbuf;
MYSQL_session* data;
unsigned int qlen;
data = subsvc->session->data;
tmpbuf = scur->scmd_cur_cmd->my_sescmd_buf;
qlen = MYSQL_GET_PACKET_LEN((unsigned char*) tmpbuf->start);
memset(data->db, 0, MYSQL_DATABASE_MAXLEN + 1);
strncpy(data->db, tmpbuf->start + 5, qlen - 1);
rc = SESSION_ROUTE_QUERY(subsvc->session,sescmd_cursor_clone_querybuf(scur));
}
/** Fallthrough */
case MYSQL_COM_QUERY:
default:
/**