Renamed the dbshard module to schemarouter.
This commit is contained in:
@ -51,7 +51,7 @@
|
||||
|
||||
## Routers
|
||||
|
||||
- [DBShard Router](routers/dbshard/DBShard.md)
|
||||
- [SchemaRouter Router](routers/schemarouter/SchemaRouter.md)
|
||||
|
||||
## Design Documents
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
#DBShard Router - Technical Overview
|
||||
#SchemaRouter Router - Technical Overview
|
||||
|
||||
This document is designed with a developer's point-of-view in mind. It explains the lifecycle of the module and details about its internal workings. It refers to the source code which can be found at [GitHub](https://github.com/mariadb-corporation/MaxScale).
|
||||
|
||||
## Source Files and Data Structures
|
||||
|
||||
The dbshard router consists of the dbshard.h header file located in the `server/modules/include/` directory and the dbshard.c file located in the `server/modules/routing/dbshard` directory. This router implements the router interface defined in the router.h file. The entry points and structures this router uses can be found in the header file. The two main structures in use are the router instace and router session structures. The router instance structure is defined in `struct router_instance` and the router session structure in `struct router_client_session`.
|
||||
The schemarouter router consists of the schemarouter.h header file located in the `server/modules/include/` directory and the schemarouter.c file located in the `server/modules/routing/schemarouter` directory. This router implements the router interface defined in the router.h file. The entry points and structures this router uses can be found in the header file. The two main structures in use are the router instace and router session structures. The router instance structure is defined in `struct router_instance` and the router session structure in `struct router_client_session`.
|
||||
|
||||
The definitions of the external functions and all the internal functions of the router can be found in the dbshard.c file.
|
||||
The definitions of the external functions and all the internal functions of the router can be found in the schemarouter.c file.
|
||||
|
||||
## Router Lifecycle
|
||||
|
||||
@ -20,4 +20,4 @@ If a response is received the clientReply function is called and response is sim
|
||||
|
||||
After the session ends the closeSession is called where the session is set to a closed state after which the freeSession is called where the final freeing of memory is done. After this point the router's session has gone through all the stages of its lifecycle.
|
||||
|
||||

|
||||

|
@ -1,14 +1,14 @@
|
||||
#DBShard Router
|
||||
#SchemaRouter Router
|
||||
|
||||
The DBShard router provides an easy and manageable sharding solution by building a single logical database server from multiple separate ones. Each database is shown to the client and queries targeting unique databases are routed to their respective servers. In addition to providing simple database-based sharding, the dbshard router also enables cross-node session variable usage by routing all queries that modify the session to all nodes.
|
||||
The SchemaRouter router provides an easy and manageable sharding solution by building a single logical database server from multiple separate ones. Each database is shown to the client and queries targeting unique databases are routed to their respective servers. In addition to providing simple database-based sharding, the schemarouter router also enables cross-node session variable usage by routing all queries that modify the session to all nodes.
|
||||
|
||||
## Configuration
|
||||
|
||||
Here is an example configuration of the dbshard router:
|
||||
Here is an example configuration of the schemarouter router:
|
||||
|
||||
[Shard Router]
|
||||
type=service
|
||||
router=dbshard
|
||||
router=schemarouter
|
||||
servers=server1,server2
|
||||
user=myuser
|
||||
passwd=mypwd
|
||||
@ -29,7 +29,7 @@ This would in effect allow the user 'john' to only see the database 'shard' on t
|
||||
|
||||
## Limitations
|
||||
|
||||
The dbshard router currently has some limitations due to the nature of the sharding implementation and the way the session variables are detected and routed. Here is a list of the current limitations.
|
||||
The schemarouter router currently has some limitations due to the nature of the sharding implementation and the way the session variables are detected and routed. Here is a list of the current limitations.
|
||||
|
||||
- Cross-database queries (e.g. SELECT column FROM database1.table UNION select column FROM database2.table) are not supported and are routed either to the first explicit database in the query, the current database in use or to the first available database, if none of the previous conditions are met.
|
||||
|
||||
@ -39,9 +39,9 @@ The dbshard router currently has some limitations due to the nature of the shard
|
||||
|
||||
- SELECT queries that modify session variables are not currently supported because uniform results can not be guaranteed. If such a query is executed, the behavior of the router is undefined. To work around this limitation the query must be executed in separate parts.
|
||||
|
||||
- Currently the dbshard router does not support connecting directly to a sharded database.
|
||||
- Currently the schemarouter router does not support connecting directly to a sharded database.
|
||||
|
||||
- Queries targeting databases not mapped by the dbshard router but still exist on the database server are not blocked but routed to the first available server. This possibly returns an error about database rights instead of a missing database. The behavior of the router is undefined in this case.
|
||||
- Queries targeting databases not mapped by the schemarouter router but still exist on the database server are not blocked but routed to the first available server. This possibly returns an error about database rights instead of a missing database. The behavior of the router is undefined in this case.
|
||||
|
||||
## Examples
|
||||
|
||||
@ -49,4 +49,4 @@ To be implemeted.
|
||||
|
||||
## Technical Documentation
|
||||
|
||||
[Technical Overview and Lifecycle Walkthrough](DBShard-technical.md)
|
||||
[Technical Overview and Lifecycle Walkthrough](SchemaRouter-technical.md)
|
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
@ -30,8 +30,8 @@ macro(set_variables)
|
||||
# port of read/write split router module
|
||||
set(TEST_PORT_RW "4006" CACHE STRING "port of read/write split router module")
|
||||
|
||||
# port of dbshard router module
|
||||
set(TEST_PORT_DB "4010" CACHE STRING "port of dbshard router module")
|
||||
# port of schemarouter router module
|
||||
set(TEST_PORT_DB "4010" CACHE STRING "port of schemarouter router module")
|
||||
|
||||
# port of read/write split router module with hints
|
||||
set(TEST_PORT_RW_HINT "4009" CACHE STRING "port of read/write split router module with hints")
|
||||
|
@ -283,7 +283,7 @@ int error_count = 0;
|
||||
char *weightby;
|
||||
char *version_string;
|
||||
bool is_rwsplit = false;
|
||||
bool is_dbshard = false;
|
||||
bool is_schemarouter = false;
|
||||
char *allow_localhost_match_wildcard_host;
|
||||
|
||||
obj->element = service_alloc(obj->object, router);
|
||||
@ -310,13 +310,13 @@ int error_count = 0;
|
||||
{
|
||||
is_rwsplit = true;
|
||||
}
|
||||
else if (strncasecmp(router, "dbshard", strlen("dbshard")+1) == 0)
|
||||
else if (strncasecmp(router, "schemarouter", strlen("schemarouter")+1) == 0)
|
||||
{
|
||||
is_dbshard = true;
|
||||
is_schemarouter = true;
|
||||
}
|
||||
else if(strncasecmp(router, "shardrouter", strlen("dbshard")+1) == 0)
|
||||
else if(strncasecmp(router, "shardrouter", strlen("schemarouter")+1) == 0)
|
||||
{
|
||||
is_dbshard = true;
|
||||
is_schemarouter = true;
|
||||
}
|
||||
if (obj->element == NULL) /*< if module load failed */
|
||||
{
|
||||
@ -467,7 +467,7 @@ int error_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(is_dbshard)
|
||||
if(is_schemarouter)
|
||||
{
|
||||
CONFIG_PARAMETER* param = NULL;
|
||||
char* subservices;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef _DBSHARDROUTER_H
|
||||
#define _DBSHARDROUTER_H
|
||||
#ifndef _SCHEMAROUTER_H
|
||||
#define _SCHEMAROUTER_H
|
||||
/*
|
||||
* 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
|
||||
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file router.h - The dbshard router module heder file
|
||||
* @file schemarouter.h - The schemarouter router module header file
|
||||
*
|
||||
* @verbatim
|
||||
* Revision History
|
||||
@ -226,11 +226,11 @@ typedef struct backend_ref_st {
|
||||
/**
|
||||
* Configuration values
|
||||
*/
|
||||
typedef struct dbshard_config_st {
|
||||
typedef struct schemarouter_config_st {
|
||||
int rw_max_slave_conn_percent;
|
||||
int rw_max_slave_conn_count;
|
||||
target_t rw_use_sql_variables_in;
|
||||
} dbshard_config_t;
|
||||
} schemarouter_config_t;
|
||||
|
||||
|
||||
/**
|
||||
@ -249,7 +249,7 @@ struct router_client_session {
|
||||
rses_property_t* rses_properties[RSES_PROP_TYPE_COUNT]; /*< Session properties */
|
||||
backend_ref_t* rses_master_ref; /*< Router session master reference */
|
||||
backend_ref_t* rses_backend_ref; /*< Pointer to backend reference array */
|
||||
dbshard_config_t rses_config; /*< Copied config info from router instance */
|
||||
schemarouter_config_t rses_config; /*< Copied config info from router instance */
|
||||
int rses_nbackends; /*< Number of backends */
|
||||
int rses_capabilities; /*< Input type, for example */
|
||||
bool rses_autocommit_enabled; /*< Is autocommit enabled */
|
||||
@ -288,8 +288,8 @@ typedef struct router_instance {
|
||||
SPINLOCK lock; /*< Lock for the instance data */
|
||||
BACKEND** servers; /*< Backend servers */
|
||||
BACKEND* master; /*< NULL or pointer */
|
||||
dbshard_config_t dbshard_config; /*< expanded config info from SERVICE */
|
||||
int dbshard_version;/*< version number for router's config */
|
||||
schemarouter_config_t schemarouter_config; /*< expanded config info from SERVICE */
|
||||
int schemarouter_version;/*< version number for router's config */
|
||||
unsigned int bitmask; /*< Bitmask to apply to server->status */
|
||||
unsigned int bitvalue; /*< Required value of server->status */
|
||||
ROUTER_STATS stats; /*< Statistics for this router */
|
||||
@ -306,4 +306,4 @@ void* dbnames_hash_init(ROUTER_INSTANCE* inst,BACKEND** backends);
|
||||
bool update_dbnames_hash(ROUTER_INSTANCE* inst,BACKEND** backends, HASHTABLE* hashtable);
|
||||
#endif
|
||||
|
||||
#endif /*< _DBSHARDROUTER_H */
|
||||
#endif /*< _SCHEMAROUTER_H */
|
@ -6,11 +6,11 @@ add_library(testroute SHARED testroute.c)
|
||||
target_link_libraries(testroute log_manager utils)
|
||||
install(TARGETS testroute DESTINATION modules)
|
||||
|
||||
add_library(dbshard SHARED dbshard/dbshard.c)
|
||||
target_link_libraries(dbshard log_manager utils query_classifier)
|
||||
install(TARGETS dbshard DESTINATION modules)
|
||||
add_library(schemarouter SHARED schemarouter/schemarouter.c)
|
||||
target_link_libraries(schemarouter log_manager utils query_classifier)
|
||||
install(TARGETS schemarouter DESTINATION modules)
|
||||
|
||||
add_library(shardrouter SHARED dbshard/shardrouter.c)
|
||||
add_library(shardrouter SHARED schemarouter/shardrouter.c)
|
||||
target_link_libraries(shardrouter log_manager utils query_classifier)
|
||||
install(TARGETS shardrouter DESTINATION modules)
|
||||
|
||||
@ -27,7 +27,7 @@ target_link_libraries(cli log_manager utils)
|
||||
install(TARGETS cli DESTINATION modules)
|
||||
|
||||
add_subdirectory(readwritesplit)
|
||||
add_subdirectory(dbshard/test)
|
||||
add_subdirectory(schemarouter/test)
|
||||
if(BUILD_BINLOG)
|
||||
add_subdirectory(binlog)
|
||||
endif()
|
||||
|
@ -1,9 +0,0 @@
|
||||
if(MYSQLCLIENT_FOUND AND BUILD_TESTS)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/test.cmake @ONLY)
|
||||
add_executable(testdbshard testdbshard.c)
|
||||
target_link_libraries(testdbshard ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
||||
add_executable(testdbshard2 testdbshard2.c)
|
||||
target_link_libraries(testdbshard2 ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
||||
add_test(NAME TestDBShard COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/test.cmake)
|
||||
|
||||
endif()
|
@ -1,17 +0,0 @@
|
||||
set(DBSHARD_TEST_PORTS 3000 3001 3002 3003)
|
||||
foreach(VAR ${DBSHARD_TEST_PORTS})
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/prepare_shard.sh @TEST_HOST@ ${VAR} @TEST_USER@ @TEST_PASSWORD@ "db${VAR}")
|
||||
endforeach()
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testdbshard @TEST_HOST@ @TEST_PORT_DB@ @TEST_USER@ @TEST_PASSWORD@ RESULT_VARIABLE RVAL)
|
||||
if(RVAL EQUAL 0)
|
||||
message("Test 1 passed.")
|
||||
else()
|
||||
message(FATAL_ERROR "Test 1 failed with code ${RVAL}.")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testdbshard2 @TEST_HOST@ @TEST_PORT_DB@ @TEST_USER@ @TEST_PASSWORD@ RESULT_VARIABLE RVAL2)
|
||||
if(RVAL2 EQUAL 0)
|
||||
message("Test 2 passed.")
|
||||
else()
|
||||
message(FATAL_ERROR "Test 2 failed with code ${RVAL2}.")
|
||||
endif()
|
@ -23,7 +23,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <router.h>
|
||||
#include <dbshard.h>
|
||||
#include <schemarouter.h>
|
||||
#include <secrets.h>
|
||||
#include <mysql.h>
|
||||
#include <skygw_utils.h>
|
||||
@ -48,7 +48,7 @@ extern int lm_enabled_logfiles_bitmask;
|
||||
extern size_t log_ses_count[];
|
||||
extern __thread log_info_t tls_log_info;
|
||||
/**
|
||||
* @file dbshard.c The entry points for the simple sharding
|
||||
* @file schemarouter.c The entry points for the simple sharding
|
||||
* router module.
|
||||
*.
|
||||
* @verbatim
|
||||
@ -271,7 +271,7 @@ bool parse_showdb_response(ROUTER_CLIENT_SES* rses, char* target, GWBUF* buf)
|
||||
{
|
||||
if(hashtable_add(rses->dbhash,row->data[0],target))
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: <%s, %s>",target,row->data[0]);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: <%s, %s>",target,row->data[0]);
|
||||
}
|
||||
|
||||
row = row->next;
|
||||
@ -320,7 +320,7 @@ int gen_databaselist(ROUTER_INSTANCE* inst, ROUTER_CLIENT_SES* session)
|
||||
clone = gwbuf_clone(buffer);
|
||||
dcb = session->rses_backend_ref[i].bref_dcb;
|
||||
rval |= !dcb->func.write(dcb,clone);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Wrote SHOW DATABASES to %s for session %p: returned %d",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Wrote SHOW DATABASES to %s for session %p: returned %d",
|
||||
session->rses_backend_ref[i].bref_backend->backend_server->unique_name,
|
||||
session->rses_client_dcb->session,
|
||||
rval);
|
||||
@ -363,7 +363,7 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: Query targets database '%s' on server '%s",dbnms[i],rval);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: Query targets database '%s' on server '%s",dbnms[i],rval);
|
||||
}
|
||||
for(j = i;j < sz;j++) free(dbnms[j]);
|
||||
break;
|
||||
@ -387,14 +387,14 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
|
||||
tmp = (char*) hashtable_fetch(ht, tok);
|
||||
|
||||
if(tmp)
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: SHOW TABLES with specific database '%s' on server '%s'", tok, tmp);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: SHOW TABLES with specific database '%s' on server '%s'", tok, tmp);
|
||||
}
|
||||
free(query);
|
||||
|
||||
if(tmp == NULL)
|
||||
{
|
||||
rval = (char*) hashtable_fetch(ht, client->rses_mysql_session->db);
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: SHOW TABLES query, current database '%s' on server '%s'",
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: SHOW TABLES query, current database '%s' on server '%s'",
|
||||
client->rses_mysql_session->db,rval);
|
||||
}
|
||||
else
|
||||
@ -416,7 +416,7 @@ char* get_shard_target_name(ROUTER_INSTANCE* router, ROUTER_CLIENT_SES* client,
|
||||
if(strcmp(srvnm,buffer->hint->data) == 0)
|
||||
{
|
||||
rval = srvnm;
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: Routing hint found (%s)",srvnm);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: Routing hint found (%s)",srvnm);
|
||||
|
||||
}
|
||||
}
|
||||
@ -605,7 +605,7 @@ static void refreshInstance(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of dbshard router within the MaxScale.
|
||||
* Create an instance of schemarouter router within the MaxScale.
|
||||
*
|
||||
*
|
||||
* @param service The service this router is being create for
|
||||
@ -698,7 +698,7 @@ createInstance(SERVICE *service, char **options)
|
||||
* Read config version number from service to inform what configuration
|
||||
* is used if any.
|
||||
*/
|
||||
router->dbshard_version = service->svc_config_version;
|
||||
router->schemarouter_version = service->svc_config_version;
|
||||
|
||||
/** refreshInstance(router, NULL); */
|
||||
/**
|
||||
@ -770,7 +770,7 @@ static void* newSession(
|
||||
strncpy(db,data->db,MYSQL_DATABASE_MAXLEN+1);
|
||||
memset(data->db,0,MYSQL_DATABASE_MAXLEN+1);
|
||||
using_db = true;
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: Client logging in directly to a database '%s', "
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: Client logging in directly to a database '%s', "
|
||||
"postponing until databases have been mapped.",db);
|
||||
}
|
||||
|
||||
@ -1656,7 +1656,7 @@ static int routeQuery(
|
||||
gen_databaselist(inst,router_cli_ses);
|
||||
|
||||
char* querystr = modutil_get_SQL(querybuf);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Storing query for session %p: %s",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Storing query for session %p: %s",
|
||||
router_cli_ses->rses_client_dcb->session,
|
||||
querystr);
|
||||
free(querystr);
|
||||
@ -1819,13 +1819,13 @@ static int routeQuery(
|
||||
|
||||
if(tname)
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: INIT_DB for database '%s' on server '%s'",
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: INIT_DB for database '%s' on server '%s'",
|
||||
router_cli_ses->rses_mysql_session->db,tname);
|
||||
route_target = TARGET_NAMED_SERVER;
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: INIT_DB with unknown database");
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: INIT_DB with unknown database");
|
||||
}
|
||||
}
|
||||
else if(route_target != TARGET_ALL &&
|
||||
@ -1839,7 +1839,7 @@ static int routeQuery(
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: Backend server '%s' is not in a viable state",tname);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: Backend server '%s' is not in a viable state",tname);
|
||||
|
||||
/**
|
||||
* Shard is not a viable target right now so we check
|
||||
@ -1889,7 +1889,7 @@ static int routeQuery(
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_ERROR, "Error : Router internal failure (dbshard)");
|
||||
skygw_log_write(LOGFILE_ERROR, "Error : Router internal failure (schemarouter)");
|
||||
/** Something else went wrong, terminate connection */
|
||||
ret = 0;
|
||||
}
|
||||
@ -1949,7 +1949,7 @@ static int routeQuery(
|
||||
{
|
||||
|
||||
/**No valid backends alive*/
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: No backends are running");
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: No backends are running");
|
||||
rses_end_locked_router_action(router_cli_ses);
|
||||
ret = 0;
|
||||
goto retblock;
|
||||
@ -2229,7 +2229,7 @@ static void clientReply (
|
||||
goto lock_failed;
|
||||
}
|
||||
bref = get_bref_from_dcb(router_cli_ses, backend_dcb);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Received reply from %s for session %p",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Received reply from %s for session %p",
|
||||
bref->bref_backend->backend_server->unique_name,
|
||||
router_cli_ses->rses_client_dcb->session);
|
||||
#if !defined(FOR_BUG548_FIX_ONLY)
|
||||
@ -2257,7 +2257,7 @@ static void clientReply (
|
||||
parse_showdb_response(router_cli_ses,
|
||||
router_cli_ses->rses_backend_ref[i].bref_backend->backend_server->unique_name,
|
||||
writebuf);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Received SHOW DATABASES reply from %s for session %p",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Received SHOW DATABASES reply from %s for session %p",
|
||||
router_cli_ses->rses_backend_ref[i].bref_backend->backend_server->unique_name,
|
||||
router_cli_ses->rses_client_dcb->session);
|
||||
}
|
||||
@ -2268,7 +2268,7 @@ static void clientReply (
|
||||
mapped = false;
|
||||
if(!logged)
|
||||
{
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Still waiting for reply to SHOW DATABASES from %s for session %p",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Still waiting for reply to SHOW DATABASES from %s for session %p",
|
||||
bkrf[i].bref_backend->backend_server->unique_name,
|
||||
router_cli_ses->rses_client_dcb->session);
|
||||
logged = true;
|
||||
@ -2295,7 +2295,7 @@ static void clientReply (
|
||||
if((target = hashtable_fetch(router_cli_ses->dbhash,
|
||||
router_cli_ses->connect_db)) == NULL)
|
||||
{
|
||||
skygw_log_write_flush(LOGFILE_TRACE,"dbshard: Connecting to a non-existent database '%s'",
|
||||
skygw_log_write_flush(LOGFILE_TRACE,"schemarouter: Connecting to a non-existent database '%s'",
|
||||
router_cli_ses->connect_db);
|
||||
router_cli_ses->rses_closed = true;
|
||||
if(router_cli_ses->queue)
|
||||
@ -2332,14 +2332,14 @@ static void clientReply (
|
||||
if(get_shard_dcb(&dcb,router_cli_ses,target))
|
||||
{
|
||||
dcb->func.write(dcb,buffer);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: USE '%s' sent to %s for session %p",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: USE '%s' sent to %s for session %p",
|
||||
router_cli_ses->connect_db,
|
||||
target,
|
||||
router_cli_ses->rses_client_dcb->session);
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write_flush(LOGFILE_TRACE,"dbshard: Couldn't find target DCB for '%s'.",target);
|
||||
skygw_log_write_flush(LOGFILE_TRACE,"schemarouter: Couldn't find target DCB for '%s'.",target);
|
||||
router_cli_ses->rses_closed = true;
|
||||
if(router_cli_ses->queue)
|
||||
gwbuf_free(router_cli_ses->queue);
|
||||
@ -2355,7 +2355,7 @@ static void clientReply (
|
||||
router_cli_ses->queue = router_cli_ses->queue->next;
|
||||
tmp->next = NULL;
|
||||
char* querystr = modutil_get_SQL(tmp);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Sending queued buffer for session %p: %s",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Sending queued buffer for session %p: %s",
|
||||
router_cli_ses->rses_client_dcb->session,
|
||||
querystr);
|
||||
poll_add_epollin_event_to_dcb(router_cli_ses->dcb_route,tmp);
|
||||
@ -2377,7 +2377,7 @@ static void clientReply (
|
||||
router_cli_ses->queue = router_cli_ses->queue->next;
|
||||
tmp->next = NULL;
|
||||
char* querystr = modutil_get_SQL(tmp);
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Sending queued buffer for session %p: %s",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Sending queued buffer for session %p: %s",
|
||||
router_cli_ses->rses_client_dcb->session,
|
||||
querystr);
|
||||
poll_add_epollin_event_to_dcb(router_cli_ses->dcb_route,tmp);
|
||||
@ -2386,7 +2386,7 @@ static void clientReply (
|
||||
|
||||
if(router_cli_ses->init & INIT_USE_DB)
|
||||
{
|
||||
skygw_log_write(LOGFILE_DEBUG,"dbshard: Reply to USE '%s' received for session %p",
|
||||
skygw_log_write(LOGFILE_DEBUG,"schemarouter: Reply to USE '%s' received for session %p",
|
||||
router_cli_ses->connect_db,
|
||||
router_cli_ses->rses_client_dcb->session);
|
||||
router_cli_ses->init &= ~INIT_USE_DB;
|
||||
@ -3902,7 +3902,7 @@ static bool handle_error_new_connection(
|
||||
}
|
||||
}
|
||||
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: Re-mapping databases");
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: Re-mapping databases");
|
||||
gen_databaselist(rses->router,rses);
|
||||
|
||||
return_succp:
|
||||
@ -3994,7 +3994,7 @@ router_handle_state_switch(
|
||||
{
|
||||
case DCB_REASON_NOT_RESPONDING:
|
||||
atomic_add(&bref->bref_backend->backend_conn_count, -1);
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: server %s not responding",srv->unique_name);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: server %s not responding",srv->unique_name);
|
||||
dcb->func.hangup(dcb);
|
||||
break;
|
||||
|
||||
@ -4051,7 +4051,7 @@ static bool change_current_db(
|
||||
memcpy(rses->rses_mysql_session->db,packet + 5,plen);
|
||||
memset(rses->rses_mysql_session->db + plen,0,1);
|
||||
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: INIT_DB with database '%s'",
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: INIT_DB with database '%s'",
|
||||
rses->rses_mysql_session->db);
|
||||
/**
|
||||
* Update the session's active database only if it's in the hashtable.
|
||||
@ -4077,7 +4077,7 @@ static bool change_current_db(
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"dbshard: database is on server: '%s'.",target);
|
||||
skygw_log_write(LOGFILE_TRACE,"schemarouter: database is on server: '%s'.",target);
|
||||
succp = true;
|
||||
goto retblock;
|
||||
}
|
||||
@ -4086,9 +4086,9 @@ static bool change_current_db(
|
||||
{
|
||||
/** Create error message */
|
||||
skygw_log_write_flush(LOGFILE_ERROR,
|
||||
"dbshard: failed to change database: Query buffer too large");
|
||||
"schemarouter: failed to change database: Query buffer too large");
|
||||
skygw_log_write_flush(LOGFILE_TRACE,
|
||||
"dbshard: failed to change database: Query buffer too large [%d bytes]",GWBUF_LENGTH(buf));
|
||||
"schemarouter: failed to change database: Query buffer too large [%d bytes]",GWBUF_LENGTH(buf));
|
||||
message_len = 25 + MYSQL_DATABASE_MAXLEN;
|
||||
fail_str = calloc(1, message_len+1);
|
||||
snprintf(fail_str,
|
||||
@ -4103,7 +4103,7 @@ reply_error:
|
||||
GWBUF* errbuf;
|
||||
skygw_log_write_flush(
|
||||
LOGFILE_TRACE,
|
||||
"dbshard: failed to change database: %s", fail_str);
|
||||
"schemarouter: failed to change database: %s", fail_str);
|
||||
errbuf = modutil_create_mysql_err_msg(1, 0, 1049, "42000", fail_str);
|
||||
free(fail_str);
|
||||
|
9
server/modules/routing/schemarouter/test/CMakeLists.txt
Normal file
9
server/modules/routing/schemarouter/test/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
if(MYSQLCLIENT_FOUND AND BUILD_TESTS)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/test.cmake @ONLY)
|
||||
add_executable(testschemarouter testschemarouter.c)
|
||||
target_link_libraries(testschemarouter ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
||||
add_executable(testschemarouter2 testschemarouter2.c)
|
||||
target_link_libraries(testschemarouter2 ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
||||
add_test(NAME TestSchemaRouter COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/test.cmake)
|
||||
|
||||
endif()
|
17
server/modules/routing/schemarouter/test/test.cmake.in
Normal file
17
server/modules/routing/schemarouter/test/test.cmake.in
Normal file
@ -0,0 +1,17 @@
|
||||
set(SCHEMAROUTER_TEST_PORTS 3000 3001 3002 3003)
|
||||
foreach(VAR ${SCHEMAROUTER_TEST_PORTS})
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/prepare_shard.sh @TEST_HOST@ ${VAR} @TEST_USER@ @TEST_PASSWORD@ "db${VAR}")
|
||||
endforeach()
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testschemarouter @TEST_HOST@ @TEST_PORT_DB@ @TEST_USER@ @TEST_PASSWORD@ RESULT_VARIABLE RVAL)
|
||||
if(RVAL EQUAL 0)
|
||||
message("Test 1 passed.")
|
||||
else()
|
||||
message(FATAL_ERROR "Test 1 failed with code ${RVAL}.")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testschemarouter2 @TEST_HOST@ @TEST_PORT_DB@ @TEST_USER@ @TEST_PASSWORD@ RESULT_VARIABLE RVAL2)
|
||||
if(RVAL2 EQUAL 0)
|
||||
message("Test 2 passed.")
|
||||
else()
|
||||
message(FATAL_ERROR "Test 2 failed with code ${RVAL2}.")
|
||||
endif()
|
@ -17,9 +17,9 @@ user=maxuser
|
||||
passwd=maxpwd
|
||||
max_slave_connections=100%
|
||||
|
||||
[DBShard Router]
|
||||
[SchemaRouter Router]
|
||||
type=service
|
||||
router=dbshard
|
||||
router=schemarouter
|
||||
servers=server1,server2,server3,server4
|
||||
user=maxuser
|
||||
passwd=maxpwd
|
||||
@ -81,9 +81,9 @@ service=RW Split Router
|
||||
protocol=MySQLClient
|
||||
port=4006
|
||||
|
||||
[DBShard Listener]
|
||||
[SchemaRouter Listener]
|
||||
type=listener
|
||||
service=DBShard Router
|
||||
service=SchemaRouter Router
|
||||
protocol=MySQLClient
|
||||
port=4010
|
||||
|
||||
|
Reference in New Issue
Block a user