Merge branch 'develop' into MAX-324
Conflicts: server/core/modutil.c
This commit is contained in:
@ -1,78 +0,0 @@
|
||||
# This file is distributed as part of the MariaDB Corporation MaxScale. It is free
|
||||
# software: you can redistribute it and/or modify it under the terms of the
|
||||
# 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 2013
|
||||
#
|
||||
# Revision History
|
||||
# Date Who Description
|
||||
# 27/06/13 Mark Riddoch Initial framework put in place
|
||||
|
||||
include ../../../../build_gateway.inc
|
||||
|
||||
LOGPATH := $(ROOT_PATH)/log_manager
|
||||
UTILSPATH := $(ROOT_PATH)/utils
|
||||
QCLASSPATH := $(ROOT_PATH)/query_classifier
|
||||
|
||||
CC=cc
|
||||
CFLAGS=-c -fPIC -I/usr/include -I../../include -I../../../include \
|
||||
-I$(LOGPATH) -I$(UTILSPATH) -I$(QCLASSPATH) \
|
||||
$(MYSQL_HEADERS) -Wall -g
|
||||
|
||||
include ../../../../makefile.inc
|
||||
|
||||
LDFLAGS=-shared -L$(LOGPATH) -L$(QCLASSPATH) -L$(EMBEDDED_LIB) \
|
||||
-Wl,-rpath,$(DEST)/lib \
|
||||
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) -Wl,-rpath,$(QCLASSPATH) \
|
||||
-Wl,-rpath,$(EMBEDDED_LIB)
|
||||
|
||||
SRCS=readwritesplit.c
|
||||
OBJ=$(SRCS:.c=.o)
|
||||
LIBS=-lssl -pthread -llog_manager -lquery_classifier -lmysqld
|
||||
MODULES=libreadwritesplit.so
|
||||
|
||||
all: $(MODULES)
|
||||
|
||||
libreadwritesplit.so: $(OBJ)
|
||||
$(CC) $(LDFLAGS) $(OBJ) $(UTILSPATH)/skygw_utils.o $(LIBS) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
$(DEL) $(OBJ) $(MODULES)
|
||||
|
||||
tags:
|
||||
ctags $(SRCS) $(HDRS)
|
||||
|
||||
depend:
|
||||
@$(DEL) depend.mk
|
||||
cc -M $(CFLAGS) $(SRCS) > depend.mk
|
||||
|
||||
install: $(MODULES)
|
||||
install -D $(MODULES) $(DEST)/modules
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantest
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test testall
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test buildtests
|
||||
|
||||
runtests:
|
||||
$(MAKE) -C runtests
|
||||
|
||||
|
||||
include depend.mk
|
@ -1368,8 +1368,27 @@ static route_target_t get_route_target (
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_ENABLE_AUTOCOMMIT) ||
|
||||
QUERY_IS_TYPE(qtype, QUERY_TYPE_DISABLE_AUTOCOMMIT))
|
||||
{
|
||||
/** hints don't affect on routing */
|
||||
target = TARGET_ALL;
|
||||
/**
|
||||
* This is problematic query because it would be routed to all
|
||||
* backends but since this is SELECT that is not possible:
|
||||
* 1. response set is not handled correctly in clientReply and
|
||||
* 2. multiple results can degrade performance.
|
||||
*/
|
||||
if (QUERY_IS_TYPE(qtype, QUERY_TYPE_READ))
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Warning : The query can't be routed to all "
|
||||
"backend servers because it includes SELECT and "
|
||||
"SQL variable modifications which is not supported. "
|
||||
"Set use_sql_variables_in=master or split the "
|
||||
"query to two, where SQL variable modifications "
|
||||
"are done in the first and the SELECT in the "
|
||||
"second one.")));
|
||||
|
||||
target = TARGET_MASTER;
|
||||
}
|
||||
target |= TARGET_ALL;
|
||||
}
|
||||
/**
|
||||
* Hints may affect on routing of the following queries
|
||||
@ -1953,7 +1972,16 @@ retblock:
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Routing function. Find out query type, backend type, and target DCB(s).
|
||||
* Then route query to found target(s).
|
||||
* @param inst router instance
|
||||
* @param rses router session
|
||||
* @param querybuf GWBUF including the query
|
||||
*
|
||||
* @return true if routing succeed or if it failed due to unsupported query.
|
||||
* false if backend failure was encountered.
|
||||
*/
|
||||
static bool route_single_stmt(
|
||||
ROUTER_INSTANCE* inst,
|
||||
ROUTER_CLIENT_SES* rses,
|
||||
@ -2139,6 +2167,50 @@ static bool route_single_stmt(
|
||||
|
||||
if (TARGET_IS_ALL(route_target))
|
||||
{
|
||||
/** Multiple, conflicting routing target. Return error */
|
||||
if (TARGET_IS_MASTER(route_target) ||
|
||||
TARGET_IS_SLAVE(route_target))
|
||||
{
|
||||
backend_ref_t* bref = rses->rses_backend_ref;
|
||||
|
||||
char* query_str = modutil_get_query(querybuf);
|
||||
char* qtype_str = skygw_get_qtype_str(qtype);
|
||||
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Can't route %s:%s:\"%s\". SELECT with "
|
||||
"session data modification is not supported "
|
||||
"if configuration parameter "
|
||||
"use_sql_variables_in=all .",
|
||||
STRPACKETTYPE(packet_type),
|
||||
qtype_str,
|
||||
(query_str == NULL ? "(empty)" : query_str))));
|
||||
|
||||
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE,
|
||||
"Unable to route the query "
|
||||
"without losing session data "
|
||||
"modification from other "
|
||||
"servers. <")));
|
||||
|
||||
while (bref != NULL && !BREF_IS_IN_USE(bref))
|
||||
{
|
||||
bref++;
|
||||
}
|
||||
|
||||
if (bref != NULL && BREF_IS_IN_USE(bref))
|
||||
{
|
||||
modutil_reply_parse_error(
|
||||
bref->bref_dcb,
|
||||
strdup("Routing query to backend failed. "
|
||||
"See the error log for further "
|
||||
"details."),
|
||||
0);
|
||||
}
|
||||
if (query_str) free (query_str);
|
||||
if (qtype_str) free(qtype_str);
|
||||
succp = true;
|
||||
goto retblock;
|
||||
}
|
||||
/**
|
||||
* It is not sure if the session command in question requires
|
||||
* response. Statement is examined in route_session_write.
|
||||
@ -4358,6 +4430,13 @@ static void handleError (
|
||||
|
||||
CHK_DCB(backend_dcb);
|
||||
|
||||
/** Reset error handle flag from a given DCB */
|
||||
if (action == ERRACT_RESET)
|
||||
{
|
||||
backend_dcb->dcb_errhandle_called = false;
|
||||
return;
|
||||
}
|
||||
|
||||
/** Don't handle same error twice on same DCB */
|
||||
if (backend_dcb->dcb_errhandle_called)
|
||||
{
|
||||
|
@ -1,36 +0,0 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../../../../build_gateway.inc
|
||||
include $(ROOT_PATH)/makefile.inc
|
||||
include $(ROOT_PATH)/test.inc
|
||||
|
||||
CC=cc
|
||||
TESTLOG := $(shell pwd)/testrwsplit.log
|
||||
RET := -1
|
||||
|
||||
cleantests:
|
||||
- $(DEL) *.o
|
||||
- $(DEL) *~
|
||||
|
||||
|
||||
testall:
|
||||
-$(MAKE) cleantests
|
||||
-$(MAKE) DEBUG=Y buildtests
|
||||
-$(MAKE) runtests
|
||||
-$(MAKE) -C test_hints testall
|
||||
|
||||
buildtests:
|
||||
|
||||
|
||||
runtests:
|
||||
@echo "" > $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Read/Write split router" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
./rwsplit.sh $(TESTLOG) $(THOST) $(TPORT_RW) $(TMASTER_ID) $(TUSER) $(TPWD)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@cat $(TESTLOG) >> $(TEST_MAXSCALE_LOG)
|
@ -1,53 +0,0 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../../../../../build_gateway.inc
|
||||
include $(ROOT_PATH)/makefile.inc
|
||||
include $(ROOT_PATH)/test.inc
|
||||
|
||||
ARGS=6
|
||||
|
||||
CC=cc
|
||||
TESTLOG := $(shell pwd)/testrwsplit_hints.log
|
||||
RET := -1
|
||||
|
||||
cleantests:
|
||||
- $(DEL) *.o
|
||||
- $(DEL) *~
|
||||
- $(DEL) *.sql
|
||||
- $(DEL) *.output
|
||||
- $(DEL) *.log
|
||||
|
||||
testall:
|
||||
-$(MAKE) cleantests
|
||||
-$(MAKE) DEBUG=Y buildtests
|
||||
-$(MAKE) runtests
|
||||
|
||||
buildtests:
|
||||
|
||||
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Read/Write split router - hint routing" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo "Running simple tests" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
./rwsplit_hints.sh $(TESTLOG) $(THOST) $(TPORT_RW_HINT) $(TMASTER_ID) $(TUSER) $(TPWD) simple_tests
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "Running syntax error tests" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
./syntax_check.sh $(TESTLOG) $(THOST) $(TPORT_RW_HINT) $(TMASTER_ID) $(TUSER) $(TPWD) error_tests
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "Running complex tests" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
./rwsplit_hints.sh $(TESTLOG) $(THOST) $(TPORT_RW_HINT) $(TMASTER_ID) $(TUSER) $(TPWD) complex_tests
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "Running stack tests" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
./rwsplit_hints.sh $(TESTLOG) $(THOST) $(TPORT_RW_HINT) $(TMASTER_ID) $(TUSER) $(TPWD) stack_tests
|
||||
@echo "" >> $(TESTLOG)
|
||||
@cat $(TESTLOG) >> $(TEST_MAXSCALE_LOG)
|
Reference in New Issue
Block a user