Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c4bcb4e1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c4bcb4e1
编写于
8月 31, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
other: adjust rsma duration for data files
上级
ed787142
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
37 deletion
+63
-37
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+63
-34
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+0
-3
未找到文件。
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
c4bcb4e1
...
...
@@ -16,17 +16,19 @@
#include "sma.h"
#include "tsdb.h"
static
int32_t
smaEvalDays
(
SRetention
*
r
,
int8_t
precision
);
static
int32_t
smaSetKeepCfg
(
STsdbKeepCfg
*
pKeepCfg
,
STsdbCfg
*
pCfg
,
int
type
);
#define RETENTION_DAYS_SPLIT_MAX (365 * 1440)
static
int32_t
smaEvalDays
(
SVnode
*
pVnode
,
SRetention
*
r
,
int8_t
level
,
int8_t
precision
,
int32_t
duration
);
static
int32_t
smaSetKeepCfg
(
SVnode
*
pVnode
,
STsdbKeepCfg
*
pKeepCfg
,
STsdbCfg
*
pCfg
,
int
type
);
static
int32_t
rsmaRestore
(
SSma
*
pSma
);
#define SMA_SET_KEEP_CFG(
l)
\
#define SMA_SET_KEEP_CFG(
v, l)
\
do { \
SRetention *r = &pCfg->retentions[l]; \
pKeepCfg->keep2 = convertTimeFromPrecisionToUnit(r->keep, pCfg->precision, TIME_UNIT_MINUTE); \
pKeepCfg->keep0 = pKeepCfg->keep2; \
pKeepCfg->keep1 = pKeepCfg->keep2; \
pKeepCfg->days = smaEvalDays(
r, pCfg->precision);
\
pKeepCfg->days = smaEvalDays(
v, pCfg->retentions, l, pCfg->precision, pCfg->days);
\
} while (0)
#define SMA_OPEN_RSMA_IMPL(v, l) \
...
...
@@ -38,51 +40,78 @@ static int32_t rsmaRestore(SSma *pSma);
} \
break; \
} \
smaSetKeepCfg(
&keepCfg, pCfg, TSDB_TYPE_RSMA_L##l);
\
smaSetKeepCfg(
v, &keepCfg, pCfg, TSDB_TYPE_RSMA_L##l);
\
if (tsdbOpen(v, &SMA_RSMA_TSDB##l(pSma), VNODE_RSMA##l##_DIR, &keepCfg) < 0) { \
goto _err; \
} \
} while (0)
#define RETENTION_DAYS_SPLIT_RATIO 10
#define RETENTION_DAYS_SPLIT_MIN 1
#define RETENTION_DAYS_SPLIT_MAX 30
/**
* @brief Evaluate days(duration) for rsma level 1/2/3.
* 1) level 1: duration from "create database"
* 2) level 2/3: duration * (freq/freqL1)
* @param pVnode
* @param r
* @param level
* @param precision
* @param duration
* @return int32_t
*/
static
int32_t
smaEvalDays
(
SVnode
*
pVnode
,
SRetention
*
r
,
int8_t
level
,
int8_t
precision
,
int32_t
duration
)
{
int32_t
freqDuration
=
convertTimeFromPrecisionToUnit
((
r
+
TSDB_RETENTION_L0
)
->
freq
,
precision
,
TIME_UNIT_MINUTE
);
int32_t
keepDuration
=
convertTimeFromPrecisionToUnit
((
r
+
TSDB_RETENTION_L0
)
->
keep
,
precision
,
TIME_UNIT_MINUTE
);
int32_t
days
=
duration
;
// min
static
int32_t
smaEvalDays
(
SRetention
*
r
,
int8_t
precis
ion
)
{
int32_t
keepDays
=
convertTimeFromPrecisionToUnit
(
r
->
keep
,
precision
,
TIME_UNIT_DAY
)
;
int32_t
freqDays
=
convertTimeFromPrecisionToUnit
(
r
->
freq
,
precision
,
TIME_UNIT_DAY
);
if
(
days
<
freqDurat
ion
)
{
days
=
freqDuration
;
}
int32_t
days
=
keepDays
/
RETENTION_DAYS_SPLIT_RATIO
;
if
(
days
<=
RETENTION_DAYS_SPLIT_MIN
)
{
days
=
RETENTION_DAYS_SPLIT_MIN
;
if
(
days
<
freqDays
)
{
days
=
freqDays
+
1
;
}
}
else
{
if
(
days
>
RETENTION_DAYS_SPLIT_MAX
)
{
days
=
RETENTION_DAYS_SPLIT_MAX
;
}
if
(
days
<
freqDays
)
{
days
=
freqDays
+
1
;
}
if
(
days
>
keepDuration
)
{
days
=
keepDuration
;
}
if
(
level
==
TSDB_RETENTION_L0
)
{
goto
end
;
}
return
days
*
1440
;
ASSERT
(
level
>=
TSDB_RETENTION_L1
&&
level
<=
TSDB_RETENTION_L2
);
freqDuration
=
convertTimeFromPrecisionToUnit
((
r
+
level
)
->
freq
,
precision
,
TIME_UNIT_MINUTE
);
keepDuration
=
convertTimeFromPrecisionToUnit
((
r
+
level
)
->
keep
,
precision
,
TIME_UNIT_MINUTE
);
int32_t
nFreqTimes
=
(
r
+
level
)
->
freq
/
(
r
+
TSDB_RETENTION_L0
)
->
freq
;
days
*=
(
nFreqTimes
>
1
?
nFreqTimes
:
1
);
if
(
days
>
keepDuration
)
{
days
=
keepDuration
;
}
if
(
days
>
RETENTION_DAYS_SPLIT_MAX
)
{
days
=
RETENTION_DAYS_SPLIT_MAX
;
}
if
(
days
<
freqDuration
)
{
days
=
freqDuration
;
}
end:
smaInfo
(
"vgId:%d, evaluated duration for level %"
PRIi8
" is %d, raw val:%d"
,
TD_VID
(
pVnode
),
level
+
1
,
days
,
duration
);
return
days
;
}
int
smaSetKeepCfg
(
STsdbKeepCfg
*
pKeepCfg
,
STsdbCfg
*
pCfg
,
int
type
)
{
int
smaSetKeepCfg
(
S
Vnode
*
pVnode
,
S
TsdbKeepCfg
*
pKeepCfg
,
STsdbCfg
*
pCfg
,
int
type
)
{
pKeepCfg
->
precision
=
pCfg
->
precision
;
switch
(
type
)
{
case
TSDB_TYPE_TSMA
:
ASSERT
(
0
);
break
;
case
TSDB_TYPE_RSMA_L0
:
SMA_SET_KEEP_CFG
(
0
);
SMA_SET_KEEP_CFG
(
pVnode
,
0
);
break
;
case
TSDB_TYPE_RSMA_L1
:
SMA_SET_KEEP_CFG
(
1
);
SMA_SET_KEEP_CFG
(
pVnode
,
1
);
break
;
case
TSDB_TYPE_RSMA_L2
:
SMA_SET_KEEP_CFG
(
2
);
SMA_SET_KEEP_CFG
(
pVnode
,
2
);
break
;
default:
ASSERT
(
0
);
...
...
@@ -148,11 +177,11 @@ int32_t smaClose(SSma *pSma) {
/**
* @brief rsma env restore
*
* @param pSma
* @param type
* @param committedVer
* @return int32_t
*
* @param pSma
* @param type
* @param committedVer
* @return int32_t
*/
int32_t
tdRsmaRestore
(
SSma
*
pSma
,
int8_t
type
,
int64_t
committedVer
)
{
ASSERT
(
VND_IS_RSMA
(
pSma
->
pVnode
));
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
c4bcb4e1
...
...
@@ -1078,9 +1078,6 @@ static int32_t tdRSmaRestoreQTaskInfoReload(SSma *pSma, int8_t type, int64_t qTa
goto
_err
;
}
SSmaEnv
*
pRSmaEnv
=
pSma
->
pRSmaEnv
;
SRSmaStat
*
pRSmaStat
=
(
SRSmaStat
*
)
SMA_ENV_STAT
(
pRSmaEnv
);
SRSmaQTaskInfoIter
fIter
=
{
0
};
if
(
tdRSmaQTaskInfoIterInit
(
&
fIter
,
&
tFile
)
<
0
)
{
tdRSmaQTaskInfoIterDestroy
(
&
fIter
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录