fix: get days per file for tsma
This commit is contained in:
parent
c086e150f5
commit
8e434be204
|
@ -47,15 +47,16 @@ int32_t tdUpdateExpireWindow(SSma* pSma, const SSubmitReq* pMsg, int64_t version
|
||||||
int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) {
|
int32_t tdGetTSmaData(SSma* pSma, char* pData, int64_t indexUid, TSKEY querySKey, int32_t nMaxResult) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if ((code = tdGetTSmaDataImpl(pSma, pData, indexUid, querySKey, nMaxResult)) < 0) {
|
if ((code = tdGetTSmaDataImpl(pSma, pData, indexUid, querySKey, nMaxResult)) < 0) {
|
||||||
smaWarn("vgId:%d, get tSma data failed since %s", SMA_VID(pSma), tstrerror(terrno));
|
smaWarn("vgId:%d, get tsma data failed since %s", SMA_VID(pSma), tstrerror(terrno));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t *days) {
|
int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t* days) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if ((code = tdGetTSmaDaysImpl(pCfg, pCont, contLen, days)) < 0) {
|
if ((code = tdGetTSmaDaysImpl(pCfg, pCont, contLen, days)) < 0) {
|
||||||
smaWarn("vgId:%d get tSma days failed since %s", pCfg->vgId, tstrerror(terrno));
|
smaWarn("vgId:%d, get tsma days failed since %s", pCfg->vgId, tstrerror(terrno));
|
||||||
}
|
}
|
||||||
|
smaDebug("vgId:%d, get tsma days %d", pCfg->vgId, *days);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,12 +97,16 @@ int32_t tdGetTSmaDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
STsdbCfg *pTsdbCfg = &pCfg->tsdbCfg;
|
STsdbCfg *pTsdbCfg = &pCfg->tsdbCfg;
|
||||||
int64_t mInterval = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_MINUTE);
|
int64_t sInterval = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_SECOND);
|
||||||
int64_t records = pTsdbCfg->days / mInterval;
|
if (sInterval <= 0) {
|
||||||
|
*days = pTsdbCfg->days;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int64_t records = pTsdbCfg->days * 60 / sInterval;
|
||||||
if (records >= SMA_STORAGE_SPLIT_FACTOR) {
|
if (records >= SMA_STORAGE_SPLIT_FACTOR) {
|
||||||
*days = pTsdbCfg->days;
|
*days = pTsdbCfg->days;
|
||||||
} else {
|
} else {
|
||||||
|
int64_t mInterval = convertTimeFromPrecisionToUnit(tsma.interval, pTsdbCfg->precision, TIME_UNIT_MINUTE);
|
||||||
int64_t daysPerFile = mInterval * SMA_STORAGE_MINUTES_DAY * 2;
|
int64_t daysPerFile = mInterval * SMA_STORAGE_MINUTES_DAY * 2;
|
||||||
|
|
||||||
if (daysPerFile > SMA_STORAGE_MINUTES_MAX) {
|
if (daysPerFile > SMA_STORAGE_MINUTES_MAX) {
|
||||||
|
@ -111,7 +115,7 @@ int32_t tdGetTSmaDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_
|
||||||
*days = (int32_t)daysPerFile;
|
*days = (int32_t)daysPerFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*days < pTsdbCfg->days) {
|
if (*days < pTsdbCfg->days) {
|
||||||
*days = pTsdbCfg->days;
|
*days = pTsdbCfg->days;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue