From 14600bf1d1ab2abb73b6ca84f80d564d491923f3 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Thu, 25 Aug 2022 01:44:16 -0500 Subject: [PATCH] enh: validate alignment of sliding windows to fill --- src/query/src/qFill.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index 1cbe1b4660..c3524c8475 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -485,6 +485,15 @@ bool taosFillHasMoreResults(SFillInfo* pFillInfo) { return false; } +bool validateAlignOfSlidingWindows(TSKEY lastKey, TSKEY currentKey, SFillInfo *pFillInfo) { + if (pFillInfo->interval.slidingUnit != 'n' && pFillInfo->interval.slidingUnit != 'y') { + assert((lastKey-currentKey)%pFillInfo->interval.sliding == 0 && + "Sliding windows not aligned." + "Most likely caused by mismatched timezones between client and/or dnodes"); + } + return true; +} + int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows) { int64_t* tsList = (int64_t*) pFillInfo->pData[0]; @@ -498,6 +507,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma int64_t numOfRes = -1; if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; + if(!validateAlignOfSlidingWindows(lastKey, pFillInfo->currentKey, pFillInfo)) return 0; numOfRes = taosTimeCountInterval( lastKey, pFillInfo->currentKey, @@ -505,7 +515,8 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma pFillInfo->interval.slidingUnit, pFillInfo->interval.intervalUnit, pFillInfo->precision); - assert(numOfRes >= numOfRows); + assert(numOfRes >= numOfRows && + "Sliding windows to fill mismatched"); } else { // reach the end of data if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) || (ekey1 > pFillInfo->currentKey && !FILL_IS_ASC_FILL(pFillInfo))) { -- GitLab