fix:[TD-31696]print error log to screen if init error
This commit is contained in:
parent
35f83bd70a
commit
f4a91c91b1
|
@ -933,7 +933,7 @@ void taos_init_imp(void) {
|
||||||
appInfo.pInstMapByClusterId =
|
appInfo.pInstMapByClusterId =
|
||||||
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_ENTRY_LOCK);
|
||||||
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
|
if (NULL == appInfo.pInstMap || NULL == appInfo.pInstMapByClusterId) {
|
||||||
tscError("failed to allocate memory when init appInfo");
|
(void)printf("failed to allocate memory when init appInfo\n");
|
||||||
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
tscInitRes = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -961,7 +961,7 @@ void taos_init_imp(void) {
|
||||||
|
|
||||||
if (InitRegexCache() != 0) {
|
if (InitRegexCache() != 0) {
|
||||||
tscInitRes = -1;
|
tscInitRes = -1;
|
||||||
tscError("failed to init regex cache");
|
(void)printf("failed to init regex cache\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -485,27 +485,27 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *input
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl)) != 0) {
|
if ((code = cfgLoad(pCfg, CFG_STYPE_APOLLO_URL, apolloUrl)) != 0) {
|
||||||
printf("failed to load from apollo url:%s since %s\n", apolloUrl, tstrerror(code));
|
(void)printf("failed to load from apollo url:%s since %s\n", apolloUrl, tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile)) != 0) {
|
if ((code = cfgLoad(pCfg, CFG_STYPE_CFG_FILE, cfgFile)) != 0) {
|
||||||
printf("failed to load from cfg file:%s since %s\n", cfgFile, tstrerror(code));
|
(void)printf("failed to load from cfg file:%s since %s\n", cfgFile, tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_FILE, envFile)) != 0) {
|
if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_FILE, envFile)) != 0) {
|
||||||
printf("failed to load from env file:%s since %s\n", envFile, tstrerror(code));
|
(void)printf("failed to load from env file:%s since %s\n", envFile, tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_VAR, NULL)) != 0) {
|
if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_VAR, NULL)) != 0) {
|
||||||
printf("failed to load from global env variables since %s\n", tstrerror(code));
|
(void)printf("failed to load from global env variables since %s\n", tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_CMD, envCmd)) != 0) {
|
if ((code = cfgLoad(pCfg, CFG_STYPE_ENV_CMD, envCmd)) != 0) {
|
||||||
printf("failed to load from cmd env variables since %s\n", tstrerror(code));
|
(void)printf("failed to load from cmd env variables since %s\n", tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1648,12 +1648,12 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != TSDB_CODE_SUCCESS) {
|
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != TSDB_CODE_SUCCESS) {
|
||||||
printf("failed to load cfg since %s\n", tstrerror(code));
|
(void)printf("failed to load cfg since %s\n", tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoadFromArray(pCfg, pArgs)) != TSDB_CODE_SUCCESS) {
|
if ((code = cfgLoadFromArray(pCfg, pArgs)) != TSDB_CODE_SUCCESS) {
|
||||||
printf("failed to load cfg from array since %s\n", tstrerror(code));
|
(void)printf("failed to load cfg from array since %s\n", tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1669,18 +1669,18 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
|
||||||
TAOS_CHECK_GOTO(taosSetAllDebugFlag(pCfg, pDebugItem->i32), &lino, _exit);
|
TAOS_CHECK_GOTO(taosSetAllDebugFlag(pCfg, pDebugItem->i32), &lino, _exit);
|
||||||
|
|
||||||
if ((code = taosMulModeMkDir(tsLogDir, 0777, true)) != TSDB_CODE_SUCCESS) {
|
if ((code = taosMulModeMkDir(tsLogDir, 0777, true)) != TSDB_CODE_SUCCESS) {
|
||||||
printf("failed to create dir:%s since %s\n", tsLogDir, tstrerror(code));
|
(void)printf("failed to create dir:%s since %s\n", tsLogDir, tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = taosInitLog(logname, logFileNum, tsc)) != 0) {
|
if ((code = taosInitLog(logname, logFileNum, tsc)) != 0) {
|
||||||
printf("failed to init log file since %s\n", tstrerror(code));
|
(void)printf("failed to init log file since %s\n", tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
printf("failed to create log at %d since %s:", lino, tstrerror(code));
|
(void)printf("failed to create log at %d since %s:", lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgCleanup(pCfg);
|
cfgCleanup(pCfg);
|
||||||
|
@ -1700,12 +1700,12 @@ int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *
|
||||||
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) ,NULL, _exit);
|
TAOS_CHECK_GOTO(cfgAddInt32(pCfg, "dDebugFlag", dDebugFlag, 0, 255, CFG_SCOPE_SERVER, CFG_DYN_SERVER) ,NULL, _exit);
|
||||||
|
|
||||||
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) {
|
if ((code = taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl)) != 0) {
|
||||||
printf("failed to load cfg since %s\n", tstrerror(code));
|
(void)printf("failed to load cfg since %s\n", tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((code = cfgLoadFromArray(pCfg, pArgs)) != 0) {
|
if ((code = cfgLoadFromArray(pCfg, pArgs)) != 0) {
|
||||||
printf("failed to load cfg from array since %s\n", tstrerror(code));
|
(void)printf("failed to load cfg from array since %s\n", tstrerror(code));
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -994,7 +994,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) {
|
||||||
const char *filepath = ".env";
|
const char *filepath = ".env";
|
||||||
if (envFile != NULL && strlen(envFile) > 0) {
|
if (envFile != NULL && strlen(envFile) > 0) {
|
||||||
if (!taosCheckExistFile(envFile)) {
|
if (!taosCheckExistFile(envFile)) {
|
||||||
printf("failed to load env file:%s\n", envFile);
|
(void)printf("failed to load env file:%s\n", envFile);
|
||||||
TAOS_RETURN(TSDB_CODE_NOT_FOUND);
|
TAOS_RETURN(TSDB_CODE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
filepath = envFile;
|
filepath = envFile;
|
||||||
|
@ -1069,7 +1069,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
uInfo("failed to load from cfg file %s since %s, use default parameters", filepath, tstrerror(code));
|
uInfo("failed to load from cfg file %s since %s, use default parameters", filepath, tstrerror(code));
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
printf("failed to load from cfg file %s since %s\n", filepath, tstrerror(code));
|
(void)printf("failed to load from cfg file %s since %s\n", filepath, tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1112,7 +1112,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 (code != 0){
|
if (code != 0){
|
||||||
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));
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break;
|
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1129,7 +1129,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
|
|
||||||
code = cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE, true);
|
code = cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE, true);
|
||||||
if (code != 0){
|
if (code != 0){
|
||||||
printf("cfg:%s, value:%s failed since %s\n", name, value, tstrerror(code));
|
(void)printf("cfg:%s, value:%s failed since %s\n", name, value, tstrerror(code));
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break;
|
if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break;
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1154,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
|
||||||
uInfo("load from cfg file %s success", filepath);
|
uInfo("load from cfg file %s success", filepath);
|
||||||
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
TAOS_RETURN(TSDB_CODE_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
printf("failed to load from cfg file %s since %s\n", filepath, tstrerror(code));
|
(void)printf("failed to load from cfg file %s since %s\n", filepath, tstrerror(code));
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1236,7 +1236,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
|
|
||||||
char *p = strchr(url, ':');
|
char *p = strchr(url, ':');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
printf("fail to load apoll url: %s, unknown format\n", url);
|
(void)printf("fail to load apoll url: %s, unknown format\n", url);
|
||||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
|
@ -1244,7 +1244,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
if (strncmp(url, "jsonFile", 8) == 0) {
|
if (strncmp(url, "jsonFile", 8) == 0) {
|
||||||
char *filepath = p;
|
char *filepath = p;
|
||||||
if (!taosCheckExistFile(filepath)) {
|
if (!taosCheckExistFile(filepath)) {
|
||||||
printf("failed to load json file:%s\n", filepath);
|
(void)printf("failed to load json file:%s\n", filepath);
|
||||||
TAOS_RETURN(TSDB_CODE_NOT_FOUND);
|
TAOS_RETURN(TSDB_CODE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1256,7 +1256,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
char *buf = taosMemoryMalloc(fileSize + 1);
|
char *buf = taosMemoryMalloc(fileSize + 1);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
printf("load json file error: %s, failed to alloc memory\n", filepath);
|
(void)printf("load json file error: %s, failed to alloc memory\n", filepath);
|
||||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,7 +1264,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
(void)taosLSeekFile(pFile, 0, SEEK_SET);
|
(void)taosLSeekFile(pFile, 0, SEEK_SET);
|
||||||
if (taosReadFile(pFile, buf, fileSize) <= 0) {
|
if (taosReadFile(pFile, buf, fileSize) <= 0) {
|
||||||
(void)taosCloseFile(&pFile);
|
(void)taosCloseFile(&pFile);
|
||||||
printf("load json file error: %s\n", filepath);
|
(void)printf("load json file error: %s\n", filepath);
|
||||||
taosMemoryFreeClear(buf);
|
taosMemoryFreeClear(buf);
|
||||||
TAOS_RETURN(TSDB_CODE_INVALID_DATA_FMT);
|
TAOS_RETURN(TSDB_CODE_INVALID_DATA_FMT);
|
||||||
}
|
}
|
||||||
|
@ -1273,7 +1273,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
if (NULL == pJson) {
|
if (NULL == pJson) {
|
||||||
const char *jsonParseError = tjsonGetError();
|
const char *jsonParseError = tjsonGetError();
|
||||||
if (jsonParseError != NULL) {
|
if (jsonParseError != NULL) {
|
||||||
printf("load json file parse error: %s\n", jsonParseError);
|
(void)printf("load json file parse error: %s\n", jsonParseError);
|
||||||
}
|
}
|
||||||
taosMemoryFreeClear(buf);
|
taosMemoryFreeClear(buf);
|
||||||
TAOS_CHECK_EXIT(TSDB_CODE_INVALID_DATA_FMT);
|
TAOS_CHECK_EXIT(TSDB_CODE_INVALID_DATA_FMT);
|
||||||
|
@ -1341,7 +1341,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) {
|
||||||
// } else if (strncmp(url, "jsonUrl", 7) == 0) {
|
// } else if (strncmp(url, "jsonUrl", 7) == 0) {
|
||||||
// } else if (strncmp(url, "etcdUrl", 7) == 0) {
|
// } else if (strncmp(url, "etcdUrl", 7) == 0) {
|
||||||
} else {
|
} else {
|
||||||
printf("Unsupported url: %s\n", url);
|
(void)printf("Unsupported url: %s\n", url);
|
||||||
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
TAOS_RETURN(TSDB_CODE_INVALID_PARA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,7 +1353,7 @@ _exit:
|
||||||
taosMemoryFree(cfgLineBuf);
|
taosMemoryFree(cfgLineBuf);
|
||||||
tjsonDelete(pJson);
|
tjsonDelete(pJson);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
printf("failed to load from apollo url:%s at line %d since %s\n", url, lino, tstrerror(code));
|
(void)printf("failed to load from apollo url:%s at line %d since %s\n", url, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,7 @@ int32_t taosInitSlowLog() {
|
||||||
(void)taosUmaskFile(0);
|
(void)taosUmaskFile(0);
|
||||||
tsLogObj.slowHandle->pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
tsLogObj.slowHandle->pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||||
if (tsLogObj.slowHandle->pFile == NULL) {
|
if (tsLogObj.slowHandle->pFile == NULL) {
|
||||||
printf("\nfailed to open slow log file:%s, reason:%s\n", name, strerror(errno));
|
(void)printf("\nfailed to open slow log file:%s, reason:%s\n", name, strerror(errno));
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ static int32_t taosInitNormalLog(const char *logName, int32_t maxFileNum) {
|
||||||
processLogFileName(logName, maxFileNum);
|
processLogFileName(logName, maxFileNum);
|
||||||
|
|
||||||
char name[PATH_MAX + 50] = "\0";
|
char name[PATH_MAX + 50] = "\0";
|
||||||
sprintf(name, "%s.%d", tsLogObj.logName, tsLogObj.flag);
|
(void)sprintf(name, "%s.%d", tsLogObj.logName, tsLogObj.flag);
|
||||||
(void)taosThreadMutexInit(&tsLogObj.logMutex, NULL);
|
(void)taosThreadMutexInit(&tsLogObj.logMutex, NULL);
|
||||||
|
|
||||||
(void)taosUmaskFile(0);
|
(void)taosUmaskFile(0);
|
||||||
|
@ -538,7 +538,7 @@ static int32_t taosInitNormalLog(const char *logName, int32_t maxFileNum) {
|
||||||
|
|
||||||
tsLogObj.logHandle->pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE);
|
tsLogObj.logHandle->pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE);
|
||||||
if (tsLogObj.logHandle->pFile == NULL) {
|
if (tsLogObj.logHandle->pFile == NULL) {
|
||||||
printf("\nfailed to open log file:%s, reason:%s\n", name, strerror(errno));
|
(void)printf("\nfailed to open log file:%s, reason:%s\n", name, strerror(errno));
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
}
|
}
|
||||||
(void)taosLockLogFile(tsLogObj.logHandle->pFile);
|
(void)taosLockLogFile(tsLogObj.logHandle->pFile);
|
||||||
|
@ -546,18 +546,18 @@ static int32_t taosInitNormalLog(const char *logName, int32_t maxFileNum) {
|
||||||
// only an estimate for number of lines
|
// only an estimate for number of lines
|
||||||
int64_t filesize = 0;
|
int64_t filesize = 0;
|
||||||
if (taosFStatFile(tsLogObj.logHandle->pFile, &filesize, NULL) < 0) {
|
if (taosFStatFile(tsLogObj.logHandle->pFile, &filesize, NULL) < 0) {
|
||||||
printf("\nfailed to fstat log file:%s, reason:%s\n", name, strerror(errno));
|
(void)printf("\nfailed to fstat log file:%s, reason:%s\n", name, strerror(errno));
|
||||||
return TAOS_SYSTEM_ERROR(errno);
|
return TAOS_SYSTEM_ERROR(errno);
|
||||||
}
|
}
|
||||||
tsLogObj.lines = (int32_t)(filesize / 60);
|
tsLogObj.lines = (int32_t)(filesize / 60);
|
||||||
|
|
||||||
(void)taosLSeekFile(tsLogObj.logHandle->pFile, 0, SEEK_END);
|
(void)taosLSeekFile(tsLogObj.logHandle->pFile, 0, SEEK_END);
|
||||||
|
|
||||||
sprintf(name, "==================================================\n");
|
(void)sprintf(name, "==================================================\n");
|
||||||
(void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name));
|
(void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name));
|
||||||
sprintf(name, " new log file \n");
|
(void)sprintf(name, " new log file \n");
|
||||||
(void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name));
|
(void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name));
|
||||||
sprintf(name, "==================================================\n");
|
(void)sprintf(name, "==================================================\n");
|
||||||
(void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name));
|
(void)taosWriteFile(tsLogObj.logHandle->pFile, name, (uint32_t)strlen(name));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue