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

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

39
.gitignore vendored
View File

@ -1,4 +1,35 @@
server/core/tags
server/core/maxscale
server/core/maxkeys
server/core/maxpasswd
# Object files
*.o
*.ko
*.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, "\n");*/
#if defined(NOT_USED)
fprintf(stderr,
"Error 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_debug_prefix,
fn->fn_debug_suffix);
#endif
succp = true;
fn->fn_state = RUN;
CHK_FNAMES_CONF(fn);
@ -2092,8 +2092,18 @@ static bool logfile_init(
logfile->lf_full_link_name =
form_full_file_name(strparts,
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
* sequence number and retry until succeeds.

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 */
if (lex->result != NULL) {
type = QUERY_TYPE_SESSION_WRITE;
type = QUERY_TYPE_GSYSVAR_WRITE;
goto return_qtype;
}
@ -543,7 +543,7 @@ static skygw_query_type_t resolve_query_type(
else if (lex->sql_command == SQLCOM_SET_OPTION)
{
/** Either user- or system variable write */
type |= QUERY_TYPE_SESSION_WRITE;
type |= QUERY_TYPE_GSYSVAR_WRITE;
}
goto return_qtype;
}
@ -759,7 +759,12 @@ static skygw_query_type_t resolve_query_type(
break;
/** User-defined variable modification */
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(
LOGFILE_DEBUG,
"%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
depend.mk
maxkeys
maxpasswd

View File

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

View File

@ -1560,77 +1560,80 @@ static bool dcb_set_state_nomutex(
case DCB_STATE_ALLOC:
switch (new_state) {
case DCB_STATE_POLLING: /*< for client requests */
case DCB_STATE_LISTENING: /*< for connect listeners */
case DCB_STATE_DISCONNECTED: /*< for failed connections */
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
/** fall through, for client requests */
case DCB_STATE_POLLING:
/** fall through, for connect listeners */
case DCB_STATE_LISTENING:
/** for failed connections */
case DCB_STATE_DISCONNECTED:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
}
break;
case DCB_STATE_POLLING:
switch(new_state) {
case DCB_STATE_NOPOLLING:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
case DCB_STATE_NOPOLLING:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
}
break;
case DCB_STATE_LISTENING:
switch(new_state) {
case DCB_STATE_NOPOLLING:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
case DCB_STATE_NOPOLLING:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
}
break;
case DCB_STATE_NOPOLLING:
switch (new_state) {
case DCB_STATE_ZOMBIE:
dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
case DCB_STATE_ZOMBIE: /*< fall through */
dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
}
break;
case DCB_STATE_ZOMBIE:
switch (new_state) {
case DCB_STATE_DISCONNECTED:
dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
case DCB_STATE_DISCONNECTED: /*< fall through */
dcb->state = new_state;
case DCB_STATE_POLLING: /*< ok to try but state can't change */
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
}
break;
case DCB_STATE_DISCONNECTED:
switch (new_state) {
case DCB_STATE_FREED:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
case DCB_STATE_FREED:
dcb->state = new_state;
succp = true;
break;
default:
ss_dassert(old_state != NULL);
break;
}
break;

View File

@ -40,7 +40,7 @@ void
spinlock_init(SPINLOCK *lock)
{
lock->lock = 0;
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
lock->spins = 0;
lock->acquired = 0;
lock->waiting = 0;
@ -57,7 +57,7 @@ spinlock_init(SPINLOCK *lock)
void
spinlock_acquire(SPINLOCK *lock)
{
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
int spins = 0;
atomic_add(&(lock->waiting), 1);
@ -65,12 +65,12 @@ int spins = 0;
while (atomic_add(&(lock->lock), 1) != 0)
{
atomic_add(&(lock->lock), -1);
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
atomic_add(&(lock->spins), 1);
spins++;
#endif
}
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
if (spins)
{
lock->contended++;
@ -97,7 +97,7 @@ spinlock_acquire_nowait(SPINLOCK *lock)
atomic_add(&(lock->lock), -1);
return FALSE;
}
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
lock->acquired++;
lock->owner = THREAD_SHELF();
#endif
@ -112,7 +112,7 @@ spinlock_acquire_nowait(SPINLOCK *lock)
void
spinlock_release(SPINLOCK *lock)
{
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
if (lock->waiting > lock->max_waiting)
lock->max_waiting = lock->waiting;
#endif
@ -135,7 +135,7 @@ spinlock_release(SPINLOCK *lock)
void
spinlock_stats(SPINLOCK *lock, void (*reporter)(void *, char *, int), void *hdl)
{
#ifdef SPINLOCK_PROFILE
#if SPINLOCK_PROFILE
reporter(hdl, "Spinlock acquired", 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 <stdbool.h>
#define SPINLOCK_PROFILE 1
#define SPINLOCK_PROFILE 0
/**
* 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++)
{
int perc;
int perc, wght;
backend = inst->servers[n];
perc = (atoi(serverGetParameter(backend->server,
weightby)) * 1000) / total;
if (perc == 0)
perc = ((wght = atoi(serverGetParameter(backend->server,
weightby))) * 1000) / total;
if (perc == 0 && wght != 0)
perc = 1;
backend->weight = perc;
if (perc == 0)
@ -279,7 +279,7 @@ char *weightby;
"for weighting parameter '%s', "
"no queries will be routed to "
"this server.\n",
server->unique_name,
inst->servers[n]->server->unique_name,
weightby)));
}
@ -418,6 +418,9 @@ BACKEND *master_host = NULL;
if (SERVER_IN_MAINT(inst->servers[i]->server))
continue;
if (inst->servers[i]->weight == 0)
continue;
/* Check server status bits against bitvalue from router_options */
if (inst->servers[i] &&
SERVER_IS_RUNNING(inst->servers[i]->server) &&

View File

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

View File

@ -613,25 +613,29 @@ createInstance(SERVICE *service, char **options)
for (n = 0; router->servers[n]; n++)
{
int perc;
int wght;
backend = router->servers[n];
perc = (atoi(serverGetParameter(
backend->backend_server,
weightby)) * 1000) / total;
if (perc == 0)
wght = atoi(serverGetParameter(backend->backend_server,
weightby));
perc = (wght*1000) / total;
if (perc == 0 && wght != 0)
{
perc = 1;
}
backend->weight = perc;
if (perc == 0)
{
LOGIF(LE, (skygw_log_write(
LOGFILE_ERROR,
LOGFILE_ERROR,
"Server '%s' has no value "
"for weighting parameter '%s', "
"no queries will be routed to "
"this server.\n",
server->unique_name,
router->servers[n]->backend_server->unique_name,
weightby)));
}
}
}
}
@ -1209,13 +1213,15 @@ static route_target_t get_route_target (
/**
* These queries are not affected by hints
*/
if (!trx_active &&
(QUERY_IS_TYPE(qtype, QUERY_TYPE_PREPARE_STMT) ||
if (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_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 */
target = TARGET_ALL;
@ -1678,8 +1684,6 @@ static int routeQuery(
}
goto retblock;
}
inst->stats.n_queries++;
master_dcb = router_cli_ses->rses_master_ref->bref_dcb;
CHK_DCB(master_dcb);
@ -1808,6 +1812,7 @@ static int routeQuery(
if (succp)
{
atomic_add(&inst->stats.n_all, 1);
ret = 1;
}
goto retblock;
@ -1904,6 +1909,10 @@ static int routeQuery(
BE_SLAVE,
NULL,
rlag_max);
if (succp)
{
atomic_add(&inst->stats.n_slave, 1);
}
}
if (!succp && TARGET_IS_MASTER(route_target))
@ -1920,21 +1929,22 @@ static int routeQuery(
{
succp = true;
}
atomic_add(&inst->stats.n_master, 1);
target_dcb = master_dcb;
}
ss_dassert(succp);
if (succp) /*< Have DCB of the target backend */
{
{
if ((ret = target_dcb->func.write(target_dcb, gwbuf_clone(querybuf))) == 1)
{
backend_ref_t* bref;
atomic_add(&inst->stats.n_slave, 1);
/**
* Add one query response waiter to backend reference
*/
atomic_add(&inst->stats.n_queries, 1);
/**
* Add one query response waiter to backend reference
*/
bref = get_bref_from_dcb(router_cli_ses, target_dcb);
bref_set_state(bref, BREF_QUERY_ACTIVE);
bref_set_state(bref, BREF_WAITING_RESULT);
@ -2446,7 +2456,10 @@ static bool select_connect_backend_servers(
master_found = true;
master_connected = true;
/* 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 */
else
@ -2568,11 +2581,17 @@ static bool select_connect_backend_servers(
* servers from the sorted list. First master found is selected.
*/
for (i=0;
i<router_nservers && (slaves_connected < max_nslaves || !master_connected);
i<router_nservers &&
(slaves_connected < max_nslaves || !master_connected);
i++)
{
BACKEND* b = backend_ref[i].bref_backend;
if (router->servers[i]->weight == 0)
{
continue;
}
if (SERVER_IS_RUNNING(b->backend_server) &&
((b->backend_server->status & router->bitmask) ==
router->bitvalue))
@ -3677,9 +3696,7 @@ static bool route_session_write(
}
/** Unlock router session */
rses_end_locked_router_action(router_cli_ses);
atomic_add(&inst->stats.n_all, 1);
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

@ -142,6 +142,12 @@ typedef enum skygw_chk_t {
((i) == LOGFILE_ERROR ? "LOGFILE_ERROR" : \
((i) == LOGFILE_DEBUG ? "LOGFILE_DEBUG" : \
"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" : \
((p) == MYSQL_COM_CREATE_DB ? "COM_CREATE_DB" : \