diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 97e6491b987370c58181d00d0ce948f897d3fa24..84aae46347292fa5b4ea66cf0c435e99494beba2 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -43,7 +43,7 @@ extern int32_t tsMaxNumOfDistinctResults; extern int32_t tsCompatibleModel; extern bool tsEnableSlaveQuery; extern bool tsPrintAuth; -extern int64_t tsTickPerDay[3]; +extern int64_t tsTickPerMin[3]; // multi-process extern bool tsMultiProcess; @@ -122,7 +122,7 @@ extern int32_t tsDiskCfgNum; extern SDiskCfg tsDiskCfg[]; // udf -extern bool tsStartUdfd; +extern bool tsStartUdfd; // internal extern int32_t tsTransPullupInterval; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 42c8e18f3e0db99fd58545ca6fef8f5449bf678c..0999cb4d2c4be55ac5b151b28b8037b74d585736 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -153,11 +153,11 @@ bool tsStreamSchedV = true; /* * minimum scale for whole system, millisecond by default - * for TSDB_TIME_PRECISION_MILLI: 86400000L - * TSDB_TIME_PRECISION_MICRO: 86400000000L - * TSDB_TIME_PRECISION_NANO: 86400000000000L + * for TSDB_TIME_PRECISION_MILLI: 60000L + * TSDB_TIME_PRECISION_MICRO: 60000000L + * TSDB_TIME_PRECISION_NANO: 60000000000L */ -int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L}; +int64_t tsTickPerMin[] = {60000L, 60000000L, 60000000000L}; // lossy compress 6 char tsLossyColumns[32] = ""; // "float|double" means all float and double columns can be lossy compressed. set empty @@ -170,7 +170,7 @@ uint32_t tsCurRange = 100; // range char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR // udf -bool tsStartUdfd = true; +bool tsStartUdfd = true; // internal int32_t tsTransPullupInterval = 6; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 6a0f4984b13cd017585449853d81cbba7cc25569..914acce2ea9aa5dbdbb8337179c43e7922cf5e72 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -144,11 +144,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { pCfg->szCache = pCreate->pages; pCfg->szBuf = pCreate->buffer * 1024 * 1024; pCfg->isWeak = true; + pCfg->tsdbCfg.compression = pCreate->compression; pCfg->tsdbCfg.precision = pCreate->precision; - pCfg->tsdbCfg.days = 10; - pCfg->tsdbCfg.keep0 = 3650; - pCfg->tsdbCfg.keep1 = 3650; - pCfg->tsdbCfg.keep2 = 3650; + pCfg->tsdbCfg.days = pCreate->daysPerFile; + pCfg->tsdbCfg.keep0 = pCreate->daysToKeep0; + pCfg->tsdbCfg.keep1 = pCreate->daysToKeep1; + pCfg->tsdbCfg.keep2 = pCreate->daysToKeep2; pCfg->tsdbCfg.minRows = pCreate->minRows; pCfg->tsdbCfg.maxRows = pCreate->maxRows; for (size_t i = 0; i < taosArrayGetSize(pCreate->pRetensions); ++i) { diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index b8cbb2d9972e8f48ad7add68f5238e00f31d93d7..c9305f6af93d9b5fb473c090b12b714aa94779fb 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -518,9 +518,9 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn); static FORCE_INLINE int TSDB_KEY_FID(TSKEY key, int32_t days, int8_t precision) { if (key < 0) { - return (int)((key + 1) / tsTickPerDay[precision] / days - 1); + return (int)((key + 1) / tsTickPerMin[precision] / days - 1); } else { - return (int)((key / tsTickPerDay[precision] / days)); + return (int)((key / tsTickPerMin[precision] / days)); } } @@ -770,8 +770,8 @@ static FORCE_INLINE int tsdbCopyDFileSet(SDFileSet *pSrc, SDFileSet *pDest) { } static FORCE_INLINE void tsdbGetFidKeyRange(int days, int8_t precision, int fid, TSKEY *minKey, TSKEY *maxKey) { - *minKey = fid * days * tsTickPerDay[precision]; - *maxKey = *minKey + days * tsTickPerDay[precision] - 1; + *minKey = fid * days * tsTickPerMin[precision]; + *maxKey = *minKey + days * tsTickPerMin[precision] - 1; } static FORCE_INLINE bool tsdbFSetIsOk(SDFileSet *pSet) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index c1813c787ad0e1465b0007632636301217c9eda0..d180799e583e9a69a44210b1fc6f9e4322ed6cee 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -216,9 +216,9 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) { TSKEY minKey, midKey, maxKey, now; now = taosGetTimestamp(pCfg->precision); - minKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision]; - midKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; - maxKey = now - pCfg->keep0 * tsTickPerDay[pCfg->precision]; + minKey = now - pCfg->keep2 * tsTickPerMin[pCfg->precision]; + midKey = now - pCfg->keep1 * tsTickPerMin[pCfg->precision]; + maxKey = now - pCfg->keep0 * tsTickPerMin[pCfg->precision]; pRtn->minKey = minKey; pRtn->minFid = (int)(TSDB_KEY_FID(minKey, pCfg->days, pCfg->precision)); @@ -398,7 +398,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) { ++mIter; } else if (pIter && !pIter->pTable) { // When table already dropped during commit, pIter is not NULL but pIter->pTable is NULL. - ++mIter; // skip the table and do nothing + ++mIter; // skip the table and do nothing } else if (pIdx) { if (tsdbMoveBlkIdx(pCommith, pIdx) < 0) { tsdbCloseCommitFile(pCommith, true); @@ -948,7 +948,6 @@ static int tsdbMoveBlkIdx(SCommitH *pCommith, SBlockIdx *pIdx) { static int tsdbSetCommitTable(SCommitH *pCommith, STable *pTable) { STSchema *pSchema = tsdbGetTableSchemaImpl(pTable, false, false, -1); - pCommith->pTable = pTable; if (tdInitDataCols(pCommith->pDataCols, pSchema) < 0) { diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 2511e3a570677db0f0ebee27cfe0b04a893d348a..b293f1399d09b0f5152ff6f737477caaafd1ecf7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -323,7 +323,7 @@ static int64_t getEarliestValidTimestamp(STsdb* pTsdb) { STsdbKeepCfg* pCfg = REPO_KEEP_CFG(pTsdb); int64_t now = taosGetTimestamp(pCfg->precision); - return now - (tsTickPerDay[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick + return now - (tsTickPerMin[pCfg->precision] * pCfg->keep2) + 1; // needs to add one tick } static void setQueryTimewindow(STsdbReadHandle* pTsdbReadHandle, SQueryTableDataCond* pCond) { @@ -1047,10 +1047,10 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio } if (key < 0) { - key -= (daysPerFile * tsTickPerDay[precision]); + key -= (daysPerFile * tsTickPerMin[precision]); } - int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerDay[precision])); // set the starting fileId + int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerMin[precision])); // set the starting fileId if (fid < 0L && llabs(fid) > INT32_MAX) { // data value overflow for INT32 fid = INT32_MIN; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 61515a3be1be3bf9b8a45bd3017e19b75ca2b939..e878668654c022fdee5c3572011172478115bd13 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -1017,7 +1017,7 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe int32_t daysPerFile = pCfg->days; if (storageLevel == SMA_STORAGE_LEVEL_TSDB) { - int32_t days = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerDay[pCfg->precision]); + int32_t days = SMA_STORAGE_TSDB_TIMES * (interval / tsTickPerMin[pCfg->precision]); daysPerFile = days > SMA_STORAGE_TSDB_DAYS ? days : SMA_STORAGE_TSDB_DAYS; } diff --git a/source/dnode/vnode/src/tsdb/tsdbWrite.c b/source/dnode/vnode/src/tsdb/tsdbWrite.c index 3107c6f5c73d0d349c62568f46874af10c08bff4..341ab94ca4fe4647d7db95d9948c4eee5d15451b 100644 --- a/source/dnode/vnode/src/tsdb/tsdbWrite.c +++ b/source/dnode/vnode/src/tsdb/tsdbWrite.c @@ -63,8 +63,8 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) { STSRow *row = NULL; STsdbKeepCfg *pCfg = REPO_KEEP_CFG(pTsdb); TSKEY now = taosGetTimestamp(pCfg->precision); - TSKEY minKey = now - tsTickPerDay[pCfg->precision] * pCfg->keep2; - TSKEY maxKey = now + tsTickPerDay[pCfg->precision] * pCfg->days; + TSKEY minKey = now - tsTickPerMin[pCfg->precision] * pCfg->keep2; + TSKEY maxKey = now + tsTickPerMin[pCfg->precision] * pCfg->days; terrno = TSDB_CODE_SUCCESS; // pMsg->length = htonl(pMsg->length);