diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 05daede777..cd0ca95d3b 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1204,8 +1204,12 @@ static int32_t taosSetSystemCfg(SConfig *pCfg) { SConfigItem *pItem = NULL; TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timezone"); - TAOS_CHECK_RETURN(osSetTimezone(pItem->str)); - uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr); + if (0 == strlen(pItem->str)) { + uError("timezone is not set"); + } else { + TAOS_CHECK_RETURN(osSetTimezone(pItem->str)); + uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr); + } TAOS_CHECK_RETURN(cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype, true)); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "locale"); @@ -1216,7 +1220,7 @@ static int32_t taosSetSystemCfg(SConfig *pCfg) { int32_t code = taosSetSystemLocale(locale, charset); if (TSDB_CODE_SUCCESS != code) { - uInfo("failed to set locale %s, since: %s", locale, tstrerror(code)); + uError("failed to set locale:%s, since: %s", locale, tstrerror(code)); char curLocale[TD_LOCALE_LEN] = {0}; char curCharset[TD_CHARSET_LEN] = {0}; taosGetSystemLocale(curLocale, curCharset); @@ -1568,13 +1572,13 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) { int32_t code = TSDB_CODE_SUCCESS; int32_t lino = 0; + SConfig *pCfg = NULL; if (tsCfg == NULL) { - TAOS_CHECK_RETURN(osDefaultInit()); + TAOS_CHECK_GOTO(osDefaultInit(), &lino, _exit); } - SConfig *pCfg = NULL; - TAOS_CHECK_RETURN(cfgInit(&pCfg)); + TAOS_CHECK_GOTO(cfgInit(&pCfg), &lino, _exit); if (tsc) { tsLogEmbedded = 0; @@ -1604,7 +1608,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi SConfigItem *pDebugItem = NULL; TAOS_CHECK_GET_CFG_ITEM(pCfg, pDebugItem, "debugFlag"); - TAOS_CHECK_RETURN(taosSetAllDebugFlag(pCfg, pDebugItem->i32)); + TAOS_CHECK_GOTO(taosSetAllDebugFlag(pCfg, pDebugItem->i32), &lino, _exit); if ((code = taosMulModeMkDir(tsLogDir, 0777, true)) != TSDB_CODE_SUCCESS) { printf("failed to create dir:%s since %s\n", tsLogDir, tstrerror(code)); diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index 72f0a41710..c6c314446d 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -47,14 +47,15 @@ char tsAVX512Supported = 0; int32_t osDefaultInit() { int32_t code = TSDB_CODE_SUCCESS; - + taosSeedRand(taosSafeRand()); taosGetSystemLocale(tsLocale, tsCharset); taosGetSystemTimezone(tsTimezoneStr, &tsTimezone); - code = taosSetSystemTimezone(tsTimezoneStr, tsTimezoneStr, &tsDaylight, &tsTimezone); - if (code) { - return code; + if (strlen(tsTimezoneStr) > 0) { // ignore empty timezone + if ((code = taosSetSystemTimezone(tsTimezoneStr, tsTimezoneStr, &tsDaylight, &tsTimezone)) != TSDB_CODE_SUCCESS) + return code; } + taosGetSystemInfo(); // deadlock in query diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index ef45b773e8..c801347fc2 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -826,7 +826,7 @@ int32_t taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, i terrno = TAOS_SYSTEM_ERROR(errno); return terrno; } - + tzset(); int32_t tz = (int32_t)((-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR); *tsTimezone = tz; diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 87551e28e0..b14b0823a3 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -244,6 +244,12 @@ static int32_t doSetConf(SConfigItem *pItem, const char *value, ECfgSrcType styp static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) { TAOS_CHECK_RETURN(doSetConf(pItem, value, stype)); + if (strlen(value) == 0) { + uError("cfg:%s, type:%s src:%s, value:%s, skip to set timezone", pItem->name, cfgDtypeStr(pItem->dtype), + cfgStypeStr(stype), value); + TAOS_RETURN(TSDB_CODE_SUCCESS); + } + TAOS_CHECK_RETURN(osSetTimezone(value)); TAOS_RETURN(TSDB_CODE_SUCCESS); }