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 * @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* * @brief Constructs a taos_collector_registry_t*

View File

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

View File

@ -66,14 +66,14 @@ taos_collector_registry_t *taos_collector_registry_new(const char *name) {
return self; return self;
} }
int taos_collector_registry_default_init(void) { void taos_collector_registry_default_init(void) {
if (TAOS_COLLECTOR_REGISTRY_DEFAULT != NULL) return 0; if (TAOS_COLLECTOR_REGISTRY_DEFAULT != NULL) return;
TAOS_COLLECTOR_REGISTRY_DEFAULT = taos_collector_registry_new("default"); TAOS_COLLECTOR_REGISTRY_DEFAULT = taos_collector_registry_new("default");
//if (TAOS_COLLECTOR_REGISTRY_DEFAULT) { //if (TAOS_COLLECTOR_REGISTRY_DEFAULT) {
// return taos_collector_registry_enable_process_metrics(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) { 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)taosThreadOnce(&cacheThreadInit, doInitRefreshThread);
(void)taosThreadMutexLock(&guard); (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)); uError("failed to add cache object into array, reason:%s", strerror(errno));
(void)taosThreadMutexUnlock(&guard); (void)taosThreadMutexUnlock(&guard);
return cacheRefreshWorker; return cacheRefreshWorker;

View File

@ -912,7 +912,7 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) {
strncpy(line, *pEnv, sizeof(line) - 1); strncpy(line, *pEnv, sizeof(line) - 1);
pEnv++; pEnv++;
if (taosEnvToCfg(line, line) < 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); (void)paGetToken(line, &name, &olen);
@ -957,7 +957,7 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) {
strncpy(buf, envCmd[index], sizeof(buf) - 1); strncpy(buf, envCmd[index], sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0; buf[sizeof(buf) - 1] = 0;
if (taosEnvToCfg(buf, buf) < 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++; index++;
@ -1031,7 +1031,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
} }
if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0; if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0;
if (taosEnvToCfg(line, line) < 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); (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); code = cfgSetItem(pConfig, name, newValue, CFG_STYPE_CFG_FILE, true);
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) { 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; break;
} }
} else { } else {
@ -1266,7 +1266,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
TAOS_CHECK_EXIT(terrno); TAOS_CHECK_EXIT(terrno);
} }
size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END); size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END);
if(fileSize <= 0) { if (fileSize <= 0) {
(void)taosCloseFile(&pFile); (void)taosCloseFile(&pFile);
(void)printf("load json file error: %s\n", filepath); (void)printf("load json file error: %s\n", filepath);
TAOS_CHECK_EXIT(terrno); TAOS_CHECK_EXIT(terrno);

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); uError("timer refCount=%d not expected 1", timer->refCount);
} }
memset(timer, 0, sizeof(*timer)); memset(timer, 0, sizeof(*timer));