Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b0789d1a
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
b0789d1a
编写于
12月 02, 2022
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: rsma logic optimization
上级
da8a337c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
21 addition
and
18 deletion
+21
-18
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+21
-18
未找到文件。
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
b0789d1a
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#define RSMA_FETCH_ACTIVE_MAX (1000) // ms
#define RSMA_FETCH_ACTIVE_MAX (1000) // ms
#define RSMA_FETCH_INTERVAL (5000) // ms
#define RSMA_FETCH_INTERVAL (5000) // ms
#define RSMA_NEED_FETCH(r) (RSMA_INFO_ITEM((r), 0)->fetchLevel || RSMA_INFO_ITEM((r), 1)->fetchLevel)
SSmaMgmt
smaMgmt
=
{
SSmaMgmt
smaMgmt
=
{
.
inited
=
0
,
.
inited
=
0
,
.
rsetId
=
-
1
,
.
rsetId
=
-
1
,
...
@@ -827,6 +829,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize,
...
@@ -827,6 +829,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize,
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
pInfo
->
pTSchema
)
{
if
(
!
pInfo
->
pTSchema
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
smaWarn
(
"vgId:%d, no schema to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
pInfo
->
suid
);
smaWarn
(
"vgId:%d, no schema to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
pInfo
->
suid
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -841,7 +844,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize,
...
@@ -841,7 +844,7 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize,
tdRsmaPrintSubmitReq(pSma, pReq);
tdRsmaPrintSubmitReq(pSma, pReq);
}
}
#endif
#endif
if
(
qSetSMAInput
(
qTaskInfo
,
pMsg
,
msgSize
,
inputType
)
<
0
)
{
if
(
(
terrno
=
qSetSMAInput
(
qTaskInfo
,
pMsg
,
msgSize
,
inputType
)
)
<
0
)
{
smaError
(
"vgId:%d, rsma %"
PRIi8
" qSetStreamInput failed since %s"
,
SMA_VID
(
pSma
),
level
,
tstrerror
(
terrno
));
smaError
(
"vgId:%d, rsma %"
PRIi8
" qSetStreamInput failed since %s"
,
SMA_VID
(
pSma
),
level
,
tstrerror
(
terrno
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -1438,7 +1441,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
...
@@ -1438,7 +1441,7 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
taosGetQitem
(
qall
,
(
void
**
)
&
msg
);
taosGetQitem
(
qall
,
(
void
**
)
&
msg
);
if
(
msg
)
{
if
(
msg
)
{
if
(
!
taosArrayPush
(
pSubmitArr
,
&
msg
))
{
if
(
!
taosArrayPush
(
pSubmitArr
,
&
msg
))
{
t
dFreeRSmaSubmitItems
(
pSubmitArr
)
;
t
errno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_err
;
goto
_err
;
}
}
}
else
{
}
else
{
...
@@ -1450,7 +1453,6 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
...
@@ -1450,7 +1453,6 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
if
(
size
>
0
)
{
if
(
size
>
0
)
{
for
(
int32_t
i
=
1
;
i
<=
TSDB_RETENTION_L2
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<=
TSDB_RETENTION_L2
;
++
i
)
{
if
(
tdExecuteRSmaImpl
(
pSma
,
pSubmitArr
->
pData
,
size
,
STREAM_INPUT__MERGED_SUBMIT
,
pInfo
,
type
,
i
)
<
0
)
{
if
(
tdExecuteRSmaImpl
(
pSma
,
pSubmitArr
->
pData
,
size
,
STREAM_INPUT__MERGED_SUBMIT
,
pInfo
,
type
,
i
)
<
0
)
{
tdFreeRSmaSubmitItems
(
pSubmitArr
);
goto
_err
;
goto
_err
;
}
}
}
}
...
@@ -1458,6 +1460,9 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
...
@@ -1458,6 +1460,9 @@ static int32_t tdRSmaBatchExec(SSma *pSma, SRSmaInfo *pInfo, STaosQall *qall, SA
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
_err:
smaError
(
"vgId:%d, batch exec for suid:%"
PRIi64
" execType:%d size:%d failed since %s"
,
SMA_VID
(
pSma
),
pInfo
->
suid
,
type
,
(
int32_t
)
taosArrayGetSize
(
pSubmitArr
),
terrstr
());
tdFreeRSmaSubmitItems
(
pSubmitArr
);
while
(
1
)
{
while
(
1
)
{
void
*
msg
=
NULL
;
void
*
msg
=
NULL
;
taosGetQitem
(
qall
,
(
void
**
)
&
msg
);
taosGetQitem
(
qall
,
(
void
**
)
&
msg
);
...
@@ -1504,8 +1509,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
...
@@ -1504,8 +1509,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
while
((
pIter
=
taosHashIterate
(
infoHash
,
pIter
)))
{
while
((
pIter
=
taosHashIterate
(
infoHash
,
pIter
)))
{
SRSmaInfo
*
pInfo
=
*
(
SRSmaInfo
**
)
pIter
;
SRSmaInfo
*
pInfo
=
*
(
SRSmaInfo
**
)
pIter
;
if
(
atomic_val_compare_exchange_8
(
&
pInfo
->
assigned
,
0
,
1
)
==
0
)
{
if
(
atomic_val_compare_exchange_8
(
&
pInfo
->
assigned
,
0
,
1
)
==
0
)
{
if
((
taosQueueItemSize
(
pInfo
->
queue
)
>
0
)
||
RSMA_INFO_ITEM
(
pInfo
,
0
)
->
fetchLevel
||
if
((
taosQueueItemSize
(
pInfo
->
queue
)
>
0
)
||
RSMA_NEED_FETCH
(
pInfo
))
{
RSMA_INFO_ITEM
(
pInfo
,
1
)
->
fetchLevel
)
{
int32_t
batchCnt
=
-
1
;
int32_t
batchCnt
=
-
1
;
int32_t
batchMax
=
taosHashGetSize
(
infoHash
)
/
tsNumOfVnodeRsmaThreads
;
int32_t
batchMax
=
taosHashGetSize
(
infoHash
)
/
tsNumOfVnodeRsmaThreads
;
bool
occupied
=
(
batchMax
<=
1
);
bool
occupied
=
(
batchMax
<=
1
);
...
@@ -1521,13 +1525,20 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
...
@@ -1521,13 +1525,20 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
smaDebug
(
"vgId:%d, batchSize:%d, execType:%"
PRIi32
,
SMA_VID
(
pSma
),
qallItemSize
,
type
);
smaDebug
(
"vgId:%d, batchSize:%d, execType:%"
PRIi32
,
SMA_VID
(
pSma
),
qallItemSize
,
type
);
}
}
if
(
RSMA_
INFO_ITEM
(
pInfo
,
0
)
->
fetchLevel
||
RSMA_INFO_ITEM
(
pInfo
,
1
)
->
fetchLevel
)
{
if
(
RSMA_
NEED_FETCH
(
pInfo
)
)
{
int8_t
oldStat
=
atomic_val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
2
);
int8_t
oldStat
=
atomic_val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
2
);
if
(
oldStat
==
0
||
if
(
oldStat
==
0
||
((
oldStat
==
2
)
&&
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
))
<
TASK_TRIGGER_STAT_PAUSED
))
{
((
oldStat
==
2
)
&&
atomic_load_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
))
<
TASK_TRIGGER_STAT_PAUSED
))
{
int32_t
oldVal
=
atomic_fetch_add_32
(
&
pRSmaStat
->
nFetchAll
,
1
);
int32_t
oldVal
=
atomic_fetch_add_32
(
&
pRSmaStat
->
nFetchAll
,
1
);
ASSERT
(
oldVal
>=
0
);
ASSERT
(
oldVal
>=
0
);
int8_t
curStat
=
atomic_load_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
));
if
(
curStat
==
1
)
{
smaDebug
(
"vgId:%d, fetch all not exec as commit stat is %"
PRIi8
,
SMA_VID
(
pSma
),
curStat
);
}
else
{
tdRSmaFetchAllResult
(
pSma
,
pInfo
);
tdRSmaFetchAllResult
(
pSma
,
pInfo
);
}
if
(
0
==
atomic_sub_fetch_32
(
&
pRSmaStat
->
nFetchAll
,
1
))
{
if
(
0
==
atomic_sub_fetch_32
(
&
pRSmaStat
->
nFetchAll
,
1
))
{
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
);
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
);
}
}
...
@@ -1537,17 +1548,9 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
...
@@ -1537,17 +1548,9 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
if
(
qallItemSize
>
0
)
{
if
(
qallItemSize
>
0
)
{
atomic_fetch_sub_64
(
&
pRSmaStat
->
nBufItems
,
qallItemSize
);
atomic_fetch_sub_64
(
&
pRSmaStat
->
nBufItems
,
qallItemSize
);
continue
;
continue
;
}
else
if
(
RSMA_INFO_ITEM
(
pInfo
,
0
)
->
fetchLevel
||
RSMA_INFO_ITEM
(
pInfo
,
1
)
->
fetchLevel
)
{
if
(
atomic_load_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
))
==
0
)
{
continue
;
}
for
(
int32_t
j
=
0
;
j
<
TSDB_RETENTION_L2
;
++
j
)
{
SRSmaInfoItem
*
pItem
=
RSMA_INFO_ITEM
(
pInfo
,
j
);
if
(
pItem
->
fetchLevel
)
{
pItem
->
fetchLevel
=
0
;
taosTmrReset
(
tdRSmaFetchTrigger
,
RSMA_FETCH_INTERVAL
,
pItem
,
smaMgmt
.
tmrHandle
,
&
pItem
->
tmrId
);
}
}
}
if
(
RSMA_NEED_FETCH
(
pInfo
))
{
continue
;
}
}
break
;
break
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录