diff --git a/source/dnode/vnode/src/tsdb/tsdbWrite.c b/source/dnode/vnode/src/tsdb/tsdbWrite.c index 6e89b47adcf425ae3b5a3a08e75294cd7c1b7d85..5949b103d5336b37fad35173a67dd700d47356b9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbWrite.c +++ b/source/dnode/vnode/src/tsdb/tsdbWrite.c @@ -14,6 +14,7 @@ */ #include "tsdb.h" +#include "vndCos.h" /** * @brief max key by precision @@ -76,9 +77,18 @@ int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq2 *pMsg) { int32_t code = 0; STsdbKeepCfg *pCfg = &pTsdb->keepCfg; TSKEY now = taosGetTimestamp(pCfg->precision); - TSKEY minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep1; + TSKEY minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep2; TSKEY maxKey = tsMaxKeyByPrecision[pCfg->precision]; int32_t size = taosArrayGetSize(pMsg->aSubmitTbData); + int32_t nlevel = tfsGetLevel(pTsdb->pVnode->pTfs); + + if (nlevel > 1 && tsS3Enabled) { + if (nlevel == 3) { + minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep1; + } else if (nlevel == 2) { + minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep0; + } + } for (int32_t i = 0; i < size; ++i) { SSubmitTbData *pData = TARRAY_GET_ELEM(pMsg->aSubmitTbData, i); diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index f75c779f4bd50935b78d81828cb383e492111000..17f34b0a34b94ebe26426858a896905afbd539d1 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -16,6 +16,7 @@ #include "tencode.h" #include "tmsg.h" #include "vnd.h" +#include "vndCos.h" #include "vnode.h" #include "vnodeInt.h" @@ -190,7 +191,18 @@ static int32_t vnodePreProcessSubmitTbData(SVnode *pVnode, SDecoder *pCoder, int } else if (pVnode->config.tsdbCfg.precision == TSDB_TIME_PRECISION_NANO) { now *= 1000000; } - TSKEY minKey = now - tsTickPerMin[pVnode->config.tsdbCfg.precision] * pVnode->config.tsdbCfg.keep2; + + int32_t nlevel = tfsGetLevel(pVnode->pTfs); + int32_t keep = pVnode->config.tsdbCfg.keep2; + if (nlevel > 1 && tsS3Enabled) { + if (nlevel == 3) { + keep = pVnode->config.tsdbCfg.keep1; + } else if (nlevel == 2) { + keep = pVnode->config.tsdbCfg.keep0; + } + } + + TSKEY minKey = now - tsTickPerMin[pVnode->config.tsdbCfg.precision] * keep; TSKEY maxKey = tsMaxKeyByPrecision[pVnode->config.tsdbCfg.precision]; if (submitTbData.flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) { uint64_t nColData;