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

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;
}