Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9600840a
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看板
提交
9600840a
编写于
8月 30, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: race condition between fetch all and commit
上级
0117a5c5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
10 deletion
+26
-10
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+9
-2
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+17
-8
未找到文件。
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
9600840a
...
...
@@ -312,15 +312,22 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pEnv
);
SRSmaStat
*
pRSmaStat
=
SMA_STAT_RSMA
(
pStat
);
int32_t
nLoops
=
0
;
// step 1: set rsma stat
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
1
);
while
(
atomic_val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
1
)
!=
0
)
{
++
nLoops
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
}
}
pRSmaStat
->
commitAppliedVer
=
pSma
->
pVnode
->
state
.
applied
;
ASSERT
(
pRSmaStat
->
commitAppliedVer
>
0
);
// step 2: wait for all triggered fetch tasks to finish
int32_t
nLoops
=
0
;
while
(
1
)
{
if
(
T_REF_VAL_GET
(
pStat
)
==
0
)
{
smaDebug
(
"vgId:%d, rsma commit, fetch tasks are all finished"
,
SMA_VID
(
pSma
));
...
...
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
9600840a
...
...
@@ -21,6 +21,7 @@
#define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt
#define RSMA_FETCH_DELAY_MAX (900000) // ms
#define RSMA_FETCH_ACTIVE_MAX (1800) // ms
#define RSMA_FETCH_INTERVAL (5000) // ms
SSmaMgmt
smaMgmt
=
{
.
inited
=
0
,
...
...
@@ -1501,13 +1502,13 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
switch
(
rsmaTriggerStat
)
{
case
TASK_TRIGGER_STAT_PAUSED
:
case
TASK_TRIGGER_STAT_CANCELLED
:
{
tdReleaseSmaRef
(
smaMgmt
.
rsetId
,
pRSmaInfo
->
refId
);
smaDebug
(
"vgId:%d, rsma fetch task not start for level %"
PRIi8
" since stat is %"
PRIi8
", rsetId rsetId:%"
PRIi64
" refId:%d"
,
SMA_VID
(
pSma
),
pItem
->
level
,
rsmaTriggerStat
,
smaMgmt
.
rsetId
,
pRSmaInfo
->
refId
);
if
(
rsmaTriggerStat
==
TASK_TRIGGER_STAT_PAUSED
)
{
taosTmrReset
(
tdRSmaFetchTrigger
,
5000
,
pItem
,
smaMgmt
.
tmrHandle
,
&
pItem
->
tmrId
);
taosTmrReset
(
tdRSmaFetchTrigger
,
RSMA_FETCH_INTERVAL
,
pItem
,
smaMgmt
.
tmrHandle
,
&
pItem
->
tmrId
);
}
tdReleaseSmaRef
(
smaMgmt
.
rsetId
,
pRSmaInfo
->
refId
);
return
;
}
default:
...
...
@@ -1518,7 +1519,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
atomic_val_compare_exchange_8
(
&
pItem
->
triggerStat
,
TASK_TRIGGER_STAT_ACTIVE
,
TASK_TRIGGER_STAT_INACTIVE
);
switch
(
fetchTriggerStat
)
{
case
TASK_TRIGGER_STAT_ACTIVE
:
{
smaDebug
(
"vgId:%d, rsma fetch task
start
ed for level:%"
PRIi8
" suid:%"
PRIi64
" since stat is active"
,
smaDebug
(
"vgId:%d, rsma fetch task
plann
ed for level:%"
PRIi8
" suid:%"
PRIi64
" since stat is active"
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
// async process
pItem
->
fetchLevel
=
pItem
->
level
;
...
...
@@ -1531,8 +1532,6 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
if
(
atomic_load_8
(
&
pRSmaInfo
->
assigned
)
==
0
)
{
tsem_post
(
&
(
pStat
->
notEmpty
));
}
smaDebug
(
"vgId:%d, rsma fetch task planned for level:%"
PRIi8
" suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pItem
->
level
,
pRSmaInfo
->
suid
);
}
break
;
case
TASK_TRIGGER_STAT_PAUSED
:
{
smaDebug
(
"vgId:%d, rsma fetch task not start for level:%"
PRIi8
" suid:%"
PRIi64
" since stat is paused"
,
...
...
@@ -1715,15 +1714,25 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
smaDebug
(
"vgId:%d, batchSize:%d, execType:%"
PRIi8
,
SMA_VID
(
pSma
),
qallItemSize
,
type
);
}
if
(
atomic_
load_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
)
)
==
0
)
{
if
(
atomic_
val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
2
)
==
0
)
{
tdRSmaFetchAllResult
(
pSma
,
pInfo
,
pSubmitArr
);
atomic_store_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
);
}
if
(
qallItemSize
>
0
)
{
atomic_fetch_sub_64
(
&
pRSmaStat
->
nBufItems
,
qallItemSize
);
continue
;
}
else
if
(
RSMA_INFO_ITEM
(
pInfo
,
0
)
->
fetchLevel
||
RSMA_INFO_ITEM
(
pInfo
,
1
)
->
fetchLevel
)
{
continue
;
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
);
}
}
}
break
;
...
...
@@ -1775,7 +1784,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
if
(
pEnv
->
flag
&
SMA_ENV_FLG_CLOSE
)
{
break
;
}
tsem_wait
(
&
pRSmaStat
->
notEmpty
);
if
((
pEnv
->
flag
&
SMA_ENV_FLG_CLOSE
)
&&
(
atomic_load_64
(
&
pRSmaStat
->
nBufItems
)
<=
0
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录