enh: handle some error logs

This commit is contained in:
Hongze Cheng 2024-09-26 18:35:00 +08:00
parent 54bc8c3e22
commit d3eab57766
6 changed files with 15 additions and 17 deletions

View File

@ -37,9 +37,9 @@ extern taos_collector_registry_t *TAOS_COLLECTOR_REGISTRY_DEFAULT;
/**
* @brief Initializes the default collector registry and enables metric collection on the executing process
* @return A non-zero integer value upon failure
* @return
*/
int taos_collector_registry_default_init(void);
void taos_collector_registry_default_init(void);
/**
* @brief Constructs a taos_collector_registry_t*

View File

@ -100,9 +100,7 @@ extern char* tsMonFwUri;
#define VNODE_ROLE "taosd_vnodes_info:role"
void monInitMonitorFW(){
if (taos_collector_registry_default_init() != 0) {
uError("failed to init default collector registry");
}
taos_collector_registry_default_init();
tsMonitor.metrics = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
taos_gauge_t *gauge = NULL;

View File

@ -66,14 +66,14 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) {
return self;
}
int taos_collector_registry_default_init(void) {
if (TAOS_COLLECTOR_REGISTRY_DEFAULT != NULL) return 0;
void taos_collector_registry_default_init(void) {
if (TAOS_COLLECTOR_REGISTRY_DEFAULT != NULL) return;
TAOS_COLLECTOR_REGISTRY_DEFAULT = taos_collector_registry_new("default");
//if (TAOS_COLLECTOR_REGISTRY_DEFAULT) {
// return taos_collector_registry_enable_process_metrics(TAOS_COLLECTOR_REGISTRY_DEFAULT);
//}
return 1;
return;
}
int taos_collector_registry_destroy(taos_collector_registry_t *self) {

View File

@ -173,7 +173,7 @@ TdThread doRegisterCacheObj(SCacheObj *pCacheObj) {
(void)taosThreadOnce(&cacheThreadInit, doInitRefreshThread);
(void)taosThreadMutexLock(&guard);
if (taosArrayPush(pCacheArrayList, &pCacheObj) != 0) {
if (taosArrayPush(pCacheArrayList, &pCacheObj) == NULL) {
uError("failed to add cache object into array, reason:%s", strerror(errno));
(void)taosThreadMutexUnlock(&guard);
return cacheRefreshWorker;

View File

@ -480,7 +480,7 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
} break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE: {
float dval = 0;
float dval = 0;
int32_t code = parseCfgReal(pVal, &dval);
if (code != TSDB_CODE_SUCCESS) {
cfgUnLock(pCfg);
@ -912,7 +912,7 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
strncpy(line, *pEnv, sizeof(line) - 1);
pEnv++;
if (taosEnvToCfg(line, line) < 0) {
uError("failed to convert env to cfg:%s", line);
uTrace("failed to convert env to cfg:%s", line);
}
(void)paGetToken(line, &name, &olen);
@ -957,7 +957,7 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
strncpy(buf, envCmd[index], sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
if (taosEnvToCfg(buf, buf) < 0) {
uError("failed to convert env to cfg:%s", buf);
uTrace("failed to convert env to cfg:%s", buf);
}
index++;
@ -1031,7 +1031,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
}
if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
if (taosEnvToCfg(line, line) < 0) {
uError("failed to convert env to cfg:%s", line);
uTrace("failed to convert env to cfg:%s", line);
}
(void)paGetToken(line, &name, &olen);
@ -1125,7 +1125,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
code = cfgSetItem(pConfig, name, newValue, CFG_STYPE_CFG_FILE, true);
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) {
(void)printf("cfg:%s, value:%s failed since %s\n", name,newValue, tstrerror(code));
(void)printf("cfg:%s, value:%s failed since %s\n", name, newValue, tstrerror(code));
break;
}
} else {
@ -1266,12 +1266,12 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
TAOS_CHECK_EXIT(terrno);
}
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
if(fileSize <= 0) {
if (fileSize <= 0) {
(void)taosCloseFile(&pFile);
(void)printf("load json file error: %s\n", filepath);
TAOS_CHECK_EXIT(terrno);
}
char *buf = taosMemoryMalloc(fileSize + 1);
char *buf = taosMemoryMalloc(fileSize + 1);
if (!buf) {
(void)taosCloseFile(&pFile);
(void)printf("load json file error: %s, failed to alloc memory\n", filepath);

View File

@ -510,7 +510,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* han
}
}
if (timer->refCount == 1) {
if (timer->refCount != 1) {
uError("timer refCount=%d not expected 1", timer->refCount);
}
memset(timer, 0, sizeof(*timer));