Merge branch 'release-1.0beta-refresh' into cmake_build

This commit is contained in:
Markus Makela
2014-09-16 12:11:17 +03:00
23 changed files with 188 additions and 120 deletions

39
.gitignore vendored
View File

@ -1,4 +1,35 @@
server/core/tags # Object files
server/core/maxscale *.o
server/core/maxkeys *.ko
server/core/maxpasswd *.lo
# Libraries
*.lib
*.a
*.la
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
# log files (from testing etc.)
*.log
# "make depend" generated stuff
depend
depend.mk
# various auto-backup stuff
*~
*#
.#*
# Vi swap files
.*.swp

2
client/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# binaries generated here
maxadmin

View File

@ -1,5 +0,0 @@
*.o
*.so
*.so.*
depend.mk

View File

@ -1603,7 +1603,7 @@ static bool fnames_conf_init(
ss_dfprintf(stderr, "%s ", argv[i]); ss_dfprintf(stderr, "%s ", argv[i]);
} }
ss_dfprintf(stderr, "\n");*/ ss_dfprintf(stderr, "\n");*/
#if defined(NOT_USED)
fprintf(stderr, fprintf(stderr,
"Error log :\t%s/%s1%s\n" "Error log :\t%s/%s1%s\n"
"Message log :\t%s/%s1%s\n" "Message log :\t%s/%s1%s\n"
@ -1621,7 +1621,7 @@ static bool fnames_conf_init(
fn->fn_logpath, fn->fn_logpath,
fn->fn_debug_prefix, fn->fn_debug_prefix,
fn->fn_debug_suffix); fn->fn_debug_suffix);
#endif
succp = true; succp = true;
fn->fn_state = RUN; fn->fn_state = RUN;
CHK_FNAMES_CONF(fn); CHK_FNAMES_CONF(fn);
@ -2093,6 +2093,16 @@ static bool logfile_init(
form_full_file_name(strparts, form_full_file_name(strparts,
logfile->lf_name_seqno, logfile->lf_name_seqno,
2); 2);
fprintf(stderr, "%s\t: %s->%s\n",
STRLOGNAME(logfile_id),
logfile->lf_full_link_name,
logfile->lf_full_file_name);
}
else
{
fprintf(stderr, "%s\t: %s\n",
STRLOGNAME(logfile_id),
logfile->lf_full_file_name);
} }
/** /**
* At least one of the files couldn't be created. Increase * At least one of the files couldn't be created. Increase

2
log_manager/test/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# binaries generated here
testlog

View File

@ -1,5 +0,0 @@
*.o
*.so
*.so.*
depend.mk

View File

@ -454,7 +454,7 @@ static skygw_query_type_t resolve_query_type(
/** SELECT ..INTO variable|OUTFILE|DUMPFILE */ /** SELECT ..INTO variable|OUTFILE|DUMPFILE */
if (lex->result != NULL) { if (lex->result != NULL) {
type = QUERY_TYPE_SESSION_WRITE; type = QUERY_TYPE_GSYSVAR_WRITE;
goto return_qtype; goto return_qtype;
} }
@ -543,7 +543,7 @@ static skygw_query_type_t resolve_query_type(
else if (lex->sql_command == SQLCOM_SET_OPTION) else if (lex->sql_command == SQLCOM_SET_OPTION)
{ {
/** Either user- or system variable write */ /** Either user- or system variable write */
type |= QUERY_TYPE_SESSION_WRITE; type |= QUERY_TYPE_GSYSVAR_WRITE;
} }
goto return_qtype; goto return_qtype;
} }
@ -759,7 +759,12 @@ static skygw_query_type_t resolve_query_type(
break; break;
/** User-defined variable modification */ /** User-defined variable modification */
case Item_func::SUSERVAR_FUNC: case Item_func::SUSERVAR_FUNC:
func_qtype |= QUERY_TYPE_SESSION_WRITE; /**
* Really it is user variable but we
* don't separate sql variables atm.
* 15.9.14
*/
func_qtype |= QUERY_TYPE_GSYSVAR_WRITE;
LOGIF(LD, (skygw_log_write( LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG, LOGFILE_DEBUG,
"%lu [resolve_query_type] " "%lu [resolve_query_type] "

2
query_classifier/test/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# binaries generated here
testmain

View File

@ -1,3 +1,4 @@
*.o # binaries generated here
maxscale maxscale
depend.mk maxkeys
maxpasswd

View File

@ -359,10 +359,10 @@ getUsers(SERVICE *service, struct users *users)
row[0], row[0],
row[1], row[1],
rc == NULL ? "NULL" : ret_ip))); rc == NULL ? "NULL" : ret_ip)));
continue;
} }
free(key.user);
} else { } else {
/* setipaddress() failed, skip user add and log this*/ /* setipaddress() failed, skip user add and log this*/
LOGIF(LE, (skygw_log_write_flush( LOGIF(LE, (skygw_log_write_flush(
@ -380,7 +380,6 @@ getUsers(SERVICE *service, struct users *users)
memcpy(users->cksum, hash, SHA_DIGEST_LENGTH); memcpy(users->cksum, hash, SHA_DIGEST_LENGTH);
free(users_data); free(users_data);
free(key.user);
mysql_free_result(result); mysql_free_result(result);
mysql_close(con); mysql_close(con);

View File

@ -1560,9 +1560,12 @@ static bool dcb_set_state_nomutex(
case DCB_STATE_ALLOC: case DCB_STATE_ALLOC:
switch (new_state) { switch (new_state) {
case DCB_STATE_POLLING: /*< for client requests */ /** fall through, for client requests */
case DCB_STATE_LISTENING: /*< for connect listeners */ case DCB_STATE_POLLING:
case DCB_STATE_DISCONNECTED: /*< for failed connections */ /** fall through, for connect listeners */
case DCB_STATE_LISTENING:
/** for failed connections */
case DCB_STATE_DISCONNECTED:
dcb->state = new_state; dcb->state = new_state;
succp = true; succp = true;
break; break;
@ -1598,7 +1601,7 @@ static bool dcb_set_state_nomutex(
case DCB_STATE_NOPOLLING: case DCB_STATE_NOPOLLING:
switch (new_state) { switch (new_state) {
case DCB_STATE_ZOMBIE: case DCB_STATE_ZOMBIE: /*< fall through */
dcb->state = new_state; dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */ case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true; succp = true;
@ -1611,7 +1614,7 @@ static bool dcb_set_state_nomutex(
case DCB_STATE_ZOMBIE: case DCB_STATE_ZOMBIE:
switch (new_state) { switch (new_state) {
case DCB_STATE_DISCONNECTED: case DCB_STATE_DISCONNECTED: /*< fall through */
dcb->state = new_state; dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */ case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true; succp = true;

View File

@ -40,7 +40,7 @@ void
spinlock_init(SPINLOCK *lock) spinlock_init(SPINLOCK *lock)
{ {
lock->lock = 0; lock->lock = 0;
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
lock->spins = 0; lock->spins = 0;
lock->acquired = 0; lock->acquired = 0;
lock->waiting = 0; lock->waiting = 0;
@ -57,7 +57,7 @@ spinlock_init(SPINLOCK *lock)
void void
spinlock_acquire(SPINLOCK *lock) spinlock_acquire(SPINLOCK *lock)
{ {
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
int spins = 0; int spins = 0;
atomic_add(&(lock->waiting), 1); atomic_add(&(lock->waiting), 1);
@ -65,12 +65,12 @@ int spins = 0;
while (atomic_add(&(lock->lock), 1) != 0) while (atomic_add(&(lock->lock), 1) != 0)
{ {
atomic_add(&(lock->lock), -1); atomic_add(&(lock->lock), -1);
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
atomic_add(&(lock->spins), 1); atomic_add(&(lock->spins), 1);
spins++; spins++;
#endif #endif
} }
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
if (spins) if (spins)
{ {
lock->contended++; lock->contended++;
@ -97,7 +97,7 @@ spinlock_acquire_nowait(SPINLOCK *lock)
atomic_add(&(lock->lock), -1); atomic_add(&(lock->lock), -1);
return FALSE; return FALSE;
} }
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
lock->acquired++; lock->acquired++;
lock->owner = THREAD_SHELF(); lock->owner = THREAD_SHELF();
#endif #endif
@ -112,7 +112,7 @@ spinlock_acquire_nowait(SPINLOCK *lock)
void void
spinlock_release(SPINLOCK *lock) spinlock_release(SPINLOCK *lock)
{ {
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
if (lock->waiting > lock->max_waiting) if (lock->waiting > lock->max_waiting)
lock->max_waiting = lock->waiting; lock->max_waiting = lock->waiting;
#endif #endif
@ -135,7 +135,7 @@ spinlock_release(SPINLOCK *lock)
void void
spinlock_stats(SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl) spinlock_stats(SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl)
{ {
#ifdef SPINLOCK_PROFILE #if SPINLOCK_PROFILE
reporter(hdl, "Spinlock acquired", lock->acquired); reporter(hdl, "Spinlock acquired", lock->acquired);
if (lock->acquired) if (lock->acquired)
{ {

2
server/core/test/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
#binaries generated here
testhash

View File

@ -31,7 +31,7 @@
#include <thread.h> #include <thread.h>
#include <stdbool.h> #include <stdbool.h>
#define SPINLOCK_PROFILE 1 #define SPINLOCK_PROFILE 0
/** /**
* The spinlock structure. * The spinlock structure.

View File

@ -1,3 +0,0 @@
*.o
*.so
depend.mk

View File

@ -1,3 +0,0 @@
*.o
*.so
depend.mk

View File

@ -1,3 +0,0 @@
*.o
*.so
depend.mk

View File

@ -264,11 +264,11 @@ char *weightby;
{ {
for (n = 0; inst->servers[n]; n++) for (n = 0; inst->servers[n]; n++)
{ {
int perc; int perc, wght;
backend = inst->servers[n]; backend = inst->servers[n];
perc = (atoi(serverGetParameter(backend->server, perc = ((wght = atoi(serverGetParameter(backend->server,
weightby)) * 1000) / total; weightby))) * 1000) / total;
if (perc == 0) if (perc == 0 && wght != 0)
perc = 1; perc = 1;
backend->weight = perc; backend->weight = perc;
if (perc == 0) if (perc == 0)
@ -279,7 +279,7 @@ char *weightby;
"for weighting parameter '%s', " "for weighting parameter '%s', "
"no queries will be routed to " "no queries will be routed to "
"this server.\n", "this server.\n",
server->unique_name, inst->servers[n]->server->unique_name,
weightby))); weightby)));
} }
@ -418,6 +418,9 @@ BACKEND *master_host = NULL;
if (SERVER_IN_MAINT(inst->servers[i]->server)) if (SERVER_IN_MAINT(inst->servers[i]->server))
continue; continue;
if (inst->servers[i]->weight == 0)
continue;
/* Check server status bits against bitvalue from router_options */ /* Check server status bits against bitvalue from router_options */
if (inst->servers[i] && if (inst->servers[i] &&
SERVER_IS_RUNNING(inst->servers[i]->server) && SERVER_IS_RUNNING(inst->servers[i]->server) &&

View File

@ -1,3 +0,0 @@
*.o
*.so
depend.mk

View File

@ -613,13 +613,18 @@ createInstance(SERVICE *service, char **options)
for (n = 0; router->servers[n]; n++) for (n = 0; router->servers[n]; n++)
{ {
int perc; int perc;
int wght;
backend = router->servers[n]; backend = router->servers[n];
perc = (atoi(serverGetParameter( wght = atoi(serverGetParameter(backend->backend_server,
backend->backend_server, weightby));
weightby)) * 1000) / total; perc = (wght*1000) / total;
if (perc == 0)
if (perc == 0 && wght != 0)
{
perc = 1; perc = 1;
}
backend->weight = perc; backend->weight = perc;
if (perc == 0) if (perc == 0)
{ {
LOGIF(LE, (skygw_log_write( LOGIF(LE, (skygw_log_write(
@ -628,10 +633,9 @@ createInstance(SERVICE *service, char **options)
"for weighting parameter '%s', " "for weighting parameter '%s', "
"no queries will be routed to " "no queries will be routed to "
"this server.\n", "this server.\n",
server->unique_name, router->servers[n]->backend_server->unique_name,
weightby))); weightby)));
} }
} }
} }
} }
@ -1209,13 +1213,15 @@ static route_target_t get_route_target (
/** /**
* These queries are not affected by hints * These queries are not affected by hints
*/ */
if (!trx_active && if (QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) ||
(QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) || QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) ||
QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT) || QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_NAMED_STMT) ||
/** Configured to allow writing variables to all nodes */ /** Configured to allow writing variables to all nodes */
(use_sql_variables_in == TYPE_ALL && (use_sql_variables_in == TYPE_ALL &&
(QUERY_IS_TYPE(qtype, QUERY_TYPE_SESSION_WRITE) || QUERY_IS_TYPE(qtype, QUERY_TYPE_GSYSVAR_WRITE)) ||
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))
{ {
/** hints don't affect on routing */ /** hints don't affect on routing */
target = TARGET_ALL; target = TARGET_ALL;
@ -1678,8 +1684,6 @@ static int routeQuery(
} }
goto retblock; goto retblock;
} }
inst->stats.n_queries++;
master_dcb = router_cli_ses->rses_master_ref->bref_dcb; master_dcb = router_cli_ses->rses_master_ref->bref_dcb;
CHK_DCB(master_dcb); CHK_DCB(master_dcb);
@ -1808,6 +1812,7 @@ static int routeQuery(
if (succp) if (succp)
{ {
atomic_add(&inst->stats.n_all, 1);
ret = 1; ret = 1;
} }
goto retblock; goto retblock;
@ -1904,6 +1909,10 @@ static int routeQuery(
BE_SLAVE, BE_SLAVE,
NULL, NULL,
rlag_max); rlag_max);
if (succp)
{
atomic_add(&inst->stats.n_slave, 1);
}
} }
if (!succp && TARGET_IS_MASTER(route_target)) if (!succp && TARGET_IS_MASTER(route_target))
@ -1920,6 +1929,7 @@ static int routeQuery(
{ {
succp = true; succp = true;
} }
atomic_add(&inst->stats.n_master, 1);
target_dcb = master_dcb; target_dcb = master_dcb;
} }
ss_dassert(succp); ss_dassert(succp);
@ -1931,7 +1941,7 @@ static int routeQuery(
{ {
backend_ref_t* bref; backend_ref_t* bref;
atomic_add(&inst->stats.n_slave, 1); atomic_add(&inst->stats.n_queries, 1);
/** /**
* Add one query response waiter to backend reference * Add one query response waiter to backend reference
*/ */
@ -2446,7 +2456,10 @@ static bool select_connect_backend_servers(
master_found = true; master_found = true;
master_connected = true; master_connected = true;
/* assert with master_host */ /* assert with master_host */
ss_dassert(master_host && ((*p_master_ref)->bref_backend->backend_server == master_host->backend_server) && SERVER_MASTER); ss_dassert(master_host &&
((*p_master_ref)->bref_backend->backend_server ==
master_host->backend_server) &&
SERVER_MASTER);
} }
/** New session or master failure case */ /** New session or master failure case */
else else
@ -2568,11 +2581,17 @@ static bool select_connect_backend_servers(
* servers from the sorted list. First master found is selected. * servers from the sorted list. First master found is selected.
*/ */
for (i=0; for (i=0;
i<router_nservers && (slaves_connected < max_nslaves || !master_connected); i<router_nservers &&
(slaves_connected < max_nslaves || !master_connected);
i++) i++)
{ {
BACKEND* b = backend_ref[i].bref_backend; BACKEND* b = backend_ref[i].bref_backend;
if (router->servers[i]->weight == 0)
{
continue;
}
if (SERVER_IS_RUNNING(b->backend_server) && if (SERVER_IS_RUNNING(b->backend_server) &&
((b->backend_server->status & router->bitmask) == ((b->backend_server->status & router->bitmask) ==
router->bitvalue)) router->bitvalue))
@ -3678,8 +3697,6 @@ static bool route_session_write(
/** Unlock router session */ /** Unlock router session */
rses_end_locked_router_action(router_cli_ses); rses_end_locked_router_action(router_cli_ses);
atomic_add(&inst->stats.n_all, 1);
return_succp: return_succp:
return succp; return succp;
} }

8
server/test/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# directories generated/filled by "make testall"
bin/
Documentation/
etc/
lib/
log/
modules/
mysql/

1
utils/.gitignore vendored
View File

@ -1 +0,0 @@
*.o

View File

@ -143,6 +143,12 @@ typedef enum skygw_chk_t {
((i) == LOGFILE_DEBUG ? "LOGFILE_DEBUG" : \ ((i) == LOGFILE_DEBUG ? "LOGFILE_DEBUG" : \
"Unknown logfile type")))) "Unknown logfile type"))))
#define STRLOGNAME(n) ((n) == LOGFILE_TRACE ? "Trace log" : \
((n) == LOGFILE_MESSAGE ? "Message log" : \
((n) == LOGFILE_ERROR ? "Error log" : \
((n) == LOGFILE_DEBUG ? "Debug log" : \
"Unknown log file type"))))
#define STRPACKETTYPE(p) ((p) == MYSQL_COM_INIT_DB ? "COM_INIT_DB" : \ #define STRPACKETTYPE(p) ((p) == MYSQL_COM_INIT_DB ? "COM_INIT_DB" : \
((p) == MYSQL_COM_CREATE_DB ? "COM_CREATE_DB" : \ ((p) == MYSQL_COM_CREATE_DB ? "COM_CREATE_DB" : \
((p) == MYSQL_COM_DROP_DB ? "COM_DROP_DB" : \ ((p) == MYSQL_COM_DROP_DB ? "COM_DROP_DB" : \