Fix writeq_high_water and writeq_low_water

The parameters were never read at startup and could not be modified at
runtime. Also the values were only read once at startup.
This commit is contained in:
Markus Mäkelä 2018-10-19 13:09:39 +03:00
parent d89cfc1810
commit 4be5d9267d
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
4 changed files with 126 additions and 38 deletions

View File

@ -566,6 +566,15 @@ json_t* config_maxscale_to_json(const char* host);
*/
uint32_t config_writeq_high_water();
/**
* Set writeq high water mark
*
* @param size The high water mark in bytes
*
* @return True if the parameter was larger than MIN_WRITEQ_HIGH_WATER
*/
bool config_set_writeq_high_water(uint32_t size);
/**
* @brief Get DCB write queue low water mark
*
@ -573,6 +582,15 @@ uint32_t config_writeq_high_water();
*/
uint32_t config_writeq_low_water();
/**
* Set writeq low water mark
*
* @param size The low water mark in bytes
*
* @return True if the parameter was larger than MIN_WRITEQ_LOW_WATER
*/
bool config_set_writeq_low_water(uint32_t size);
/**
* @brief Interpret a @disk_space_threshold configuration string.
*

View File

@ -40,6 +40,7 @@
#include <vector>
#include <unordered_set>
#include <maxbase/atomic.hh>
#include <maxbase/format.hh>
#include <maxscale/adminusers.h>
#include <maxscale/alloc.h>
@ -2087,13 +2088,40 @@ unsigned int config_nbpolls()
uint32_t config_writeq_high_water()
{
return gateway.writeq_high_water;
return mxb::atomic::load(&gateway.writeq_high_water, mxb::atomic::RELAXED);
}
bool config_set_writeq_high_water(uint32_t size)
{
bool rval = false;
if (size >= MIN_WRITEQ_HIGH_WATER)
{
mxb::atomic::store(&gateway.writeq_high_water, size, mxb::atomic::RELAXED);
rval = true;
}
return rval;
}
uint32_t config_writeq_low_water()
{
return gateway.writeq_low_water;
return mxb::atomic::load(&gateway.writeq_low_water, mxb::atomic::RELAXED);
}
bool config_set_writeq_low_water(uint32_t size)
{
bool rval = false;
if (size >= MIN_WRITEQ_LOW_WATER)
{
mxb::atomic::store(&gateway.writeq_low_water, size, mxb::atomic::RELAXED);
rval = true;
}
return rval;
}
/**
* Return the configured number of milliseconds for which we wait when we do
* a blocking poll call.
@ -2480,42 +2508,6 @@ static int handle_global_item(const char* name, const char* value)
gateway.users_refresh_time = users_refresh_time;
}
else if (strcmp(name, CN_WRITEQ_HIGH_WATER) == 0)
{
if (!get_suffixed_size(value, &gateway.writeq_high_water))
{
MXS_ERROR("Invalid value for %s: %s", CN_WRITEQ_HIGH_WATER, value);
return 0;
}
if (gateway.writeq_high_water < MIN_WRITEQ_HIGH_WATER)
{
MXS_WARNING("The specified writeq high water mark %lu, is smaller "
"than the minimum allowed size %lu. Changing to minimum.",
gateway.writeq_high_water,
MIN_WRITEQ_HIGH_WATER);
gateway.writeq_high_water = MIN_WRITEQ_HIGH_WATER;
}
MXS_NOTICE("Writeq high water mark set to: %lu", gateway.writeq_high_water);
}
else if (strcmp(name, CN_WRITEQ_LOW_WATER) == 0)
{
if (!get_suffixed_size(value, &gateway.writeq_low_water))
{
MXS_ERROR("Invalid value for %s: %s", CN_WRITEQ_LOW_WATER, value);
return 0;
}
if (gateway.writeq_low_water < MIN_WRITEQ_LOW_WATER)
{
MXS_WARNING("The specified writeq low water mark %lu, is smaller "
"than the minimum allowed size %lu. Changing to minimum.",
gateway.writeq_low_water,
MIN_WRITEQ_LOW_WATER);
gateway.writeq_low_water = MIN_WRITEQ_LOW_WATER;
}
MXS_NOTICE("Writeq low water mark set to: %lu", gateway.writeq_low_water);
}
else
{
MXS_ERROR("%s is an invalid value for '%s', using default %d instead.",
@ -2525,6 +2517,42 @@ static int handle_global_item(const char* name, const char* value)
gateway.users_refresh_time = USERS_REFRESH_TIME_DEFAULT;
}
}
else if (strcmp(name, CN_WRITEQ_HIGH_WATER) == 0)
{
if (!get_suffixed_size(value, &gateway.writeq_high_water))
{
MXS_ERROR("Invalid value for %s: %s", CN_WRITEQ_HIGH_WATER, value);
return 0;
}
if (gateway.writeq_high_water < MIN_WRITEQ_HIGH_WATER)
{
MXS_WARNING("The specified writeq high water mark %lu, is smaller "
"than the minimum allowed size %lu. Changing to minimum.",
gateway.writeq_high_water,
MIN_WRITEQ_HIGH_WATER);
gateway.writeq_high_water = MIN_WRITEQ_HIGH_WATER;
}
MXS_NOTICE("Writeq high water mark set to: %lu", gateway.writeq_high_water);
}
else if (strcmp(name, CN_WRITEQ_LOW_WATER) == 0)
{
if (!get_suffixed_size(value, &gateway.writeq_low_water))
{
MXS_ERROR("Invalid value for %s: %s", CN_WRITEQ_LOW_WATER, value);
return 0;
}
if (gateway.writeq_low_water < MIN_WRITEQ_LOW_WATER)
{
MXS_WARNING("The specified writeq low water mark %lu, is smaller "
"than the minimum allowed size %lu. Changing to minimum.",
gateway.writeq_low_water,
MIN_WRITEQ_LOW_WATER);
gateway.writeq_low_water = MIN_WRITEQ_LOW_WATER;
}
MXS_NOTICE("Writeq low water mark set to: %lu", gateway.writeq_low_water);
}
else if (strcmp(name, CN_RETAIN_LAST_STATEMENTS) == 0)
{
char* endptr;

View File

@ -870,6 +870,46 @@ bool runtime_alter_maxscale(const char* name, const char* value)
config_runtime_error("Invalid size value for '%s': %s", CN_QUERY_CLASSIFIER_CACHE_SIZE, value);
}
}
else if (key == CN_WRITEQ_HIGH_WATER)
{
uint64_t size = 0;
if (!get_suffixed_size(value, &size))
{
config_runtime_error("Invalid value for %s: %s", CN_WRITEQ_HIGH_WATER, value);
}
else if (size < MIN_WRITEQ_HIGH_WATER)
{
config_runtime_error("The specified '%s' is smaller than the minimum allowed size %lu.",
CN_WRITEQ_HIGH_WATER, MIN_WRITEQ_HIGH_WATER);
}
else
{
rval = true;
config_set_writeq_high_water(size);
MXS_NOTICE("'%s' set to: %lu", CN_WRITEQ_HIGH_WATER, size);
}
}
else if (key == CN_WRITEQ_LOW_WATER)
{
uint64_t size = 0;
if (!get_suffixed_size(value, &size))
{
config_runtime_error("Invalid value for '%s': %s", CN_WRITEQ_LOW_WATER, value);
}
else if (size < MIN_WRITEQ_LOW_WATER)
{
config_runtime_error("The specified '%s' is smaller than the minimum allowed size %lu.",
CN_WRITEQ_LOW_WATER, MIN_WRITEQ_LOW_WATER);
}
else
{
rval = true;
config_set_writeq_low_water(size);
MXS_NOTICE("'%s' set to: %lu", CN_WRITEQ_LOW_WATER, size);
}
}
else
{
config_runtime_error("Unknown global parameter: %s=%s", name, value);

View File

@ -193,6 +193,8 @@ DCB* dcb_alloc(dcb_role_t role, SERV_LISTENER* listener)
newdcb->dcb_role = role;
newdcb->listener = listener;
newdcb->last_read = mxs_clock();
newdcb->low_water = config_writeq_low_water();
newdcb->high_water = config_writeq_high_water();
if (role == DCB_ROLE_SERVICE_LISTENER)
{