Skip to content

Commit 51aedde

Browse files
committed
fix(timezone): add error handling for local timezone offset retrieval in dmSendStatusReq
1 parent 521a819 commit 51aedde

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

source/common/src/ttime.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,16 +897,23 @@ static int64_t truncateToLocalMidnight(int64_t ticks, int32_t precision, timezon
897897
time_t t_sec = (time_t)t_sec_ticks;
898898
struct tm tm_local;
899899
if (taosLocalTime(&t_sec, &tm_local, NULL, 0, tz) == NULL) {
900+
uWarn("%s failed to convert ticks:%" PRId64 " to local time, code:%d",
901+
__FUNCTION__, ticks, ERRNO);
900902
return ticks;
901903
}
902904
tm_local.tm_sec = 0;
903905
tm_local.tm_min = 0;
904906
tm_local.tm_hour = 0;
905-
// Let mktime resolve DST for the target midnight instead of reusing the
906-
// DST state from the original timestamp.
907+
/*
908+
* Let mktime resolve DST for the target midnight instead of reusing the
909+
* DST state from the original timestamp.
910+
* NOTE: on Windows, taosMktime uses a fixed offset from WindowsTimezoneObj
911+
* and ignores tm_isdst, so DST-aware alignment is not supported there.
912+
*/
907913
tm_local.tm_isdst = -1;
908914
time_t midnight = taosMktime(&tm_local, tz);
909915
if (midnight == (time_t)-1) {
916+
uWarn("%s taosMktime failed for ticks:%" PRId64 ", code:%d", __FUNCTION__, ticks, ERRNO);
910917
return ticks;
911918
}
912919
return (int64_t)midnight * factor;

source/dnode/mgmt/mgmt_dnode/src/dmHandle.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
205205
req.clusterCfg.monitorParas.tsSlowLogScope = tsSlowLogScope;
206206
req.clusterCfg.monitorParas.tsSlowLogMaxLen = tsSlowLogMaxLen;
207207
req.clusterCfg.monitorParas.tsSlowLogThreshold = tsSlowLogThreshold;
208-
req.clusterCfg.checkTime = taosGetLocalTimezoneOffset();
208+
req.clusterCfg.checkTime = (int64_t)taosGetLocalTimezoneOffset(&code);
209+
if (code != 0) {
210+
dError("failed to get local timezone offset, since %s", tstrerror(code));
211+
(void)taosThreadMutexUnlock(&pMgmt->pData->statusInfolock);
212+
return;
213+
}
214+
209215
tstrncpy(req.clusterCfg.monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb, TSDB_DB_NAME_LEN);
210216
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
211217
memcpy(req.clusterCfg.locale, tsLocale, TD_LOCALE_LEN);

0 commit comments

Comments
 (0)