fix: (errcode) ignore empty timezone str

This commit is contained in:
Shungang Li 2024-08-05 15:01:35 +08:00
parent 37fc4f5674
commit 1ef464cd78
4 changed files with 23 additions and 12 deletions

View File

@ -1204,8 +1204,12 @@ static int32_t taosSetSystemCfg(SConfig *pCfg) {
SConfigItem *pItem = NULL; SConfigItem *pItem = NULL;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timezone"); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "timezone");
TAOS_CHECK_RETURN(osSetTimezone(pItem->str)); if (0 == strlen(pItem->str)) {
uDebug("timezone format changed from %s to %s", pItem->str, tsTimezoneStr); 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_RETURN(cfgSetItem(pCfg, "timezone", tsTimezoneStr, pItem->stype, true));
TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "locale"); TAOS_CHECK_GET_CFG_ITEM(pCfg, pItem, "locale");
@ -1216,7 +1220,7 @@ static int32_t taosSetSystemCfg(SConfig *pCfg) {
int32_t code = taosSetSystemLocale(locale, charset); int32_t code = taosSetSystemLocale(locale, charset);
if (TSDB_CODE_SUCCESS != code) { 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 curLocale[TD_LOCALE_LEN] = {0};
char curCharset[TD_CHARSET_LEN] = {0}; char curCharset[TD_CHARSET_LEN] = {0};
taosGetSystemLocale(curLocale, curCharset); 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) { const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc) {
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0; int32_t lino = 0;
SConfig *pCfg = NULL;
if (tsCfg == NULL) { if (tsCfg == NULL) {
TAOS_CHECK_RETURN(osDefaultInit()); TAOS_CHECK_GOTO(osDefaultInit(), &lino, _exit);
} }
SConfig *pCfg = NULL; TAOS_CHECK_GOTO(cfgInit(&pCfg), &lino, _exit);
TAOS_CHECK_RETURN(cfgInit(&pCfg));
if (tsc) { if (tsc) {
tsLogEmbedded = 0; tsLogEmbedded = 0;
@ -1604,7 +1608,7 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
SConfigItem *pDebugItem = NULL; SConfigItem *pDebugItem = NULL;
TAOS_CHECK_GET_CFG_ITEM(pCfg, pDebugItem, "debugFlag"); 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) { if ((code = taosMulModeMkDir(tsLogDir, 0777, true)) != TSDB_CODE_SUCCESS) {
printf("failed to create dir:%s since %s\n", tsLogDir, tstrerror(code)); printf("failed to create dir:%s since %s\n", tsLogDir, tstrerror(code));

View File

@ -51,10 +51,11 @@ int32_t osDefaultInit() {
taosSeedRand(taosSafeRand()); taosSeedRand(taosSafeRand());
taosGetSystemLocale(tsLocale, tsCharset); taosGetSystemLocale(tsLocale, tsCharset);
taosGetSystemTimezone(tsTimezoneStr, &tsTimezone); taosGetSystemTimezone(tsTimezoneStr, &tsTimezone);
code = taosSetSystemTimezone(tsTimezoneStr, tsTimezoneStr, &tsDaylight, &tsTimezone); if (strlen(tsTimezoneStr) > 0) { // ignore empty timezone
if (code) { if ((code = taosSetSystemTimezone(tsTimezoneStr, tsTimezoneStr, &tsDaylight, &tsTimezone)) != TSDB_CODE_SUCCESS)
return code; return code;
} }
taosGetSystemInfo(); taosGetSystemInfo();
// deadlock in query // deadlock in query

View File

@ -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) { static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) {
TAOS_CHECK_RETURN(doSetConf(pItem, value, 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_CHECK_RETURN(osSetTimezone(value));
TAOS_RETURN(TSDB_CODE_SUCCESS); TAOS_RETURN(TSDB_CODE_SUCCESS);
} }