enh: support config randErrorDivisor dynamically
This commit is contained in:
parent
c9a4466422
commit
ee05a536ef
|
@ -125,6 +125,7 @@ extern "C" {
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
extern int32_t tsRandErrChance;
|
extern int32_t tsRandErrChance;
|
||||||
|
extern int64_t tsRandErrDivisor;
|
||||||
extern threadlocal bool tsEnableRandErr;
|
extern threadlocal bool tsEnableRandErr;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -734,6 +734,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "compactPullupInterval", tsCompactPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "compactPullupInterval", tsCompactPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "mqRebalanceInterval", tsMqRebalanceInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "mqRebalanceInterval", tsMqRebalanceInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "randErrorChance", tsRandErrChance, 0, 10000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "randErrorChance", tsRandErrChance, 0, 10000, CFG_SCOPE_BOTH, CFG_DYN_NONE));
|
||||||
|
TAOS_CHECK_RETURN(cfgAddInt64(pCfg, "randErrorDivisor", tsRandErrDivisor, 1, INT64_MAX, CFG_SCOPE_BOTH, CFG_DYN_SERVER));
|
||||||
|
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlUnit", tsTtlUnit, 1, 86400 * 365, CFG_SCOPE_SERVER, CFG_DYN_NONE));
|
||||||
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushIntervalSec, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
TAOS_CHECK_RETURN(cfgAddInt32(pCfg, "ttlPushInterval", tsTtlPushIntervalSec, 1, 100000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER));
|
||||||
|
@ -1427,6 +1428,9 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "randErrorChance");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "randErrorChance");
|
||||||
tsRandErrChance = pItem->i32;
|
tsRandErrChance = pItem->i32;
|
||||||
|
|
||||||
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "randErrorDivisor");
|
||||||
|
tsRandErrDivisor = pItem->i64;
|
||||||
|
|
||||||
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlUnit");
|
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "ttlUnit");
|
||||||
tsTtlUnit = pItem->i32;
|
tsTtlUnit = pItem->i32;
|
||||||
|
|
||||||
|
@ -1881,6 +1885,7 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, const char *name) {
|
||||||
|
|
||||||
{"mndSdbWriteDelta", &tsMndSdbWriteDelta},
|
{"mndSdbWriteDelta", &tsMndSdbWriteDelta},
|
||||||
{"minDiskFreeSize", &tsMinDiskFreeSize},
|
{"minDiskFreeSize", &tsMinDiskFreeSize},
|
||||||
|
{"randErrorDivisor", &tsRandErrDivisor},
|
||||||
|
|
||||||
{"cacheLazyLoadThreshold", &tsCacheLazyLoadThreshold},
|
{"cacheLazyLoadThreshold", &tsCacheLazyLoadThreshold},
|
||||||
{"checkpointInterval", &tsStreamCheckpointInterval},
|
{"checkpointInterval", &tsStreamCheckpointInterval},
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef struct TdFile {
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
#define STUB_RAND_IO_ERR(ret) \
|
#define STUB_RAND_IO_ERR(ret) \
|
||||||
if (tsEnableRandErr) { \
|
if (tsEnableRandErr) { \
|
||||||
uint32_t r = taosRand() % 10001; \
|
uint32_t r = taosRand() % tsRandErrDivisor; \
|
||||||
if ((r + 1) <= tsRandErrChance) { \
|
if ((r + 1) <= tsRandErrChance) { \
|
||||||
errno = EIO; \
|
errno = EIO; \
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno); \
|
terrno = TAOS_SYSTEM_ERROR(errno); \
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
int32_t tsRandErrChance = 1;
|
int32_t tsRandErrChance = 1;
|
||||||
|
int64_t tsRandErrDivisor = 10001;
|
||||||
threadlocal bool tsEnableRandErr = 0;
|
threadlocal bool tsEnableRandErr = 0;
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_TD_MEMORY) || defined(USE_ADDR2LINE)
|
#if defined(USE_TD_MEMORY) || defined(USE_ADDR2LINE)
|
||||||
|
|
||||||
#define TD_MEMORY_SYMBOL ('T' << 24 | 'A' << 16 | 'O' << 8 | 'S')
|
#define TD_MEMORY_SYMBOL ('T' << 24 | 'A' << 16 | 'O' << 8 | 'S')
|
||||||
|
@ -273,7 +273,7 @@ void *taosMemoryMalloc(int64_t size) {
|
||||||
|
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
if (tsEnableRandErr) {
|
if (tsEnableRandErr) {
|
||||||
uint32_t r = taosRand() % 10001;
|
uint32_t r = taosRand() % tsRandErrDivisor;
|
||||||
if ((r + 1) <= tsRandErrChance) {
|
if ((r + 1) <= tsRandErrChance) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -303,7 +303,7 @@ void *taosMemoryCalloc(int64_t num, int64_t size) {
|
||||||
#else
|
#else
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
if (tsEnableRandErr) {
|
if (tsEnableRandErr) {
|
||||||
uint32_t r = taosRand() % 10001;
|
uint32_t r = taosRand() % tsRandErrDivisor;
|
||||||
if ((r + 1) <= tsRandErrChance) {
|
if ((r + 1) <= tsRandErrChance) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -343,7 +343,7 @@ void *taosMemoryRealloc(void *ptr, int64_t size) {
|
||||||
#else
|
#else
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
if (tsEnableRandErr) {
|
if (tsEnableRandErr) {
|
||||||
uint32_t r = taosRand() % 10001;
|
uint32_t r = taosRand() % tsRandErrDivisor;
|
||||||
if ((r + 1) <= tsRandErrChance) {
|
if ((r + 1) <= tsRandErrChance) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -378,7 +378,7 @@ char *taosStrdup(const char *ptr) {
|
||||||
#else
|
#else
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
if (tsEnableRandErr) {
|
if (tsEnableRandErr) {
|
||||||
uint32_t r = taosRand() % 10001;
|
uint32_t r = taosRand() % tsRandErrDivisor;
|
||||||
if ((r + 1) <= tsRandErrChance) {
|
if ((r + 1) <= tsRandErrChance) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -444,7 +444,7 @@ void *taosMemoryMallocAlign(uint32_t alignment, int64_t size) {
|
||||||
#if defined(LINUX)
|
#if defined(LINUX)
|
||||||
#ifdef BUILD_WITH_RAND_ERR
|
#ifdef BUILD_WITH_RAND_ERR
|
||||||
if (tsEnableRandErr) {
|
if (tsEnableRandErr) {
|
||||||
uint32_t r = taosRand() % 10001;
|
uint32_t r = taosRand() % tsRandErrDivisor;
|
||||||
if ((r + 1) <= tsRandErrChance) {
|
if ((r + 1) <= tsRandErrChance) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue