From 53eb026559311e6d4c2a060562b684cf8cc1bb0d Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 27 Aug 2024 10:23:02 +0800 Subject: [PATCH 1/4] fix:[TD-31696] decimal number check error in config file because precision different in float and double --- include/util/tutil.h | 2 +- source/client/src/clientMonitor.c | 2 +- source/util/src/tconfig.c | 4 ++-- source/util/src/tutil.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/util/tutil.h b/include/util/tutil.h index 6c7517f630..6321d2011a 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -55,7 +55,7 @@ void taosIpPort2String(uint32_t ip, uint16_t port, char *str); void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen); -int32_t parseCfgReal(const char *str, double *out); +int32_t parseCfgReal(const char *str, float *out); static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { T_MD5_CTX context; diff --git a/source/client/src/clientMonitor.c b/source/client/src/clientMonitor.c index 10e6695ee5..6144019fb8 100644 --- a/source/client/src/clientMonitor.c +++ b/source/client/src/clientMonitor.c @@ -691,7 +691,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) { continue; } if (taosLockFile(pFile) < 0) { - tscError("failed to lock file:%s since %s, maybe used by other process", filename, terrstr()); + tscInfo("failed to lock file:%s since %s, maybe used by other process", filename, terrstr()); (void)taosCloseFile(&pFile); continue; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index b14b0823a3..9fc6061612 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -191,7 +191,7 @@ static int32_t cfgSetInt64(SConfigItem *pItem, const char *value, ECfgSrcType st } static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType stype) { - double dval; + float dval = 0; TAOS_CHECK_RETURN(parseCfgReal(value, &dval)); if (dval < pItem->fmin || dval > pItem->fmax) { uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype), @@ -473,7 +473,7 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p } break; case CFG_DTYPE_FLOAT: case CFG_DTYPE_DOUBLE: { - double dval; + float dval = 0; int32_t code = parseCfgReal(pVal, &dval); if (code != TSDB_CODE_SUCCESS) { cfgUnLock(pCfg); diff --git a/source/util/src/tutil.c b/source/util/src/tutil.c index 94f514e208..6e26203d31 100644 --- a/source/util/src/tutil.c +++ b/source/util/src/tutil.c @@ -506,11 +506,11 @@ size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rs return index; } -int32_t parseCfgReal(const char *str, double *out) { - double val; +int32_t parseCfgReal(const char *str, float *out) { + float val; char *endPtr; errno = 0; - val = taosStr2Double(str, &endPtr); + val = taosStr2Float(str, &endPtr); if (str == endPtr || errno == ERANGE || isnan(val)) { return terrno = TSDB_CODE_INVALID_CFG_VALUE; } From 1b075efb0e2bd910248948863e5be56dff81cfdd Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 27 Aug 2024 11:14:25 +0800 Subject: [PATCH 2/4] fix:[TD-31694]add specific error log if load config file error --- source/util/src/tconfig.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 9fc6061612..5abe943320 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -383,6 +383,10 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy (void)taosThreadMutexUnlock(&pCfg->lock); } + if (code != 0){ + uError("cfg:%s, type:%s src:%s value:%s failed since %s", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value, tstrerror(code)); + } TAOS_RETURN(code); } From 132be58f2ab689a2375b15216b7d1951dab2e7dd Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 27 Aug 2024 13:50:52 +0800 Subject: [PATCH 3/4] fix:[TD-31696]print the float number in a compact way --- source/util/src/tconfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 5abe943320..5f0ab9a321 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -194,7 +194,7 @@ static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType st float dval = 0; TAOS_CHECK_RETURN(parseCfgReal(value, &dval)); if (dval < pItem->fmin || dval > pItem->fmax) { - uError("cfg:%s, type:%s src:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype), + uError("cfg:%s, type:%s src:%s value:%g out of range[%g, %g]", pItem->name, cfgDtypeStr(pItem->dtype), cfgStypeStr(stype), dval, pItem->fmin, pItem->fmax); TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE); } @@ -484,7 +484,7 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p TAOS_RETURN(code); } if (dval < pItem->fmin || dval > pItem->fmax) { - uError("cfg:%s, type:%s value:%f out of range[%f, %f]", pItem->name, cfgDtypeStr(pItem->dtype), dval, + uError("cfg:%s, type:%s value:%g out of range[%g, %g]", pItem->name, cfgDtypeStr(pItem->dtype), dval, pItem->fmin, pItem->fmax); cfgUnLock(pCfg); TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE); From a2e7e18440ebd4e6c6e640a12f45d969c37b6b09 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 28 Aug 2024 10:13:25 +0800 Subject: [PATCH 4/4] fix:[TD-31696] change fmin/fmax in SConfigItem from double to float --- include/util/tconfig.h | 4 ++-- source/util/src/tconfig.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/util/tconfig.h b/include/util/tconfig.h index f109153384..3fc247982f 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -84,11 +84,11 @@ typedef struct SConfigItem { }; union { int64_t imin; - double fmin; + float fmin; }; union { int64_t imax; - double fmax; + float fmax; }; SArray *array; // SDiskCfg/SLogVar } SConfigItem; diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 5f0ab9a321..42689617a3 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -199,7 +199,7 @@ static int32_t cfgSetFloat(SConfigItem *pItem, const char *value, ECfgSrcType st TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE); } - pItem->fval = (float)dval; + pItem->fval = dval; pItem->stype = stype; TAOS_RETURN(TSDB_CODE_SUCCESS); }