Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1fb2df03
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看板
提交
1fb2df03
编写于
1月 28, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: rsma close and commit refactor
上级
fe8a4631
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
16 deletion
+33
-16
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+2
-0
source/dnode/vnode/src/sma/smaCommit.c
source/dnode/vnode/src/sma/smaCommit.c
+24
-10
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+1
-0
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+6
-6
未找到文件。
source/dnode/vnode/src/inc/sma.h
浏览文件 @
1fb2df03
...
...
@@ -209,6 +209,8 @@ static FORCE_INLINE void tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
smaDebug
(
"vgId:%d, unref sma stat:%p, val:%d"
,
SMA_VID
(
pSma
),
pStat
,
ref
);
}
int32_t
smaPreClose
(
SSma
*
pSma
);
// rsma
void
*
tdFreeRSmaInfo
(
SSma
*
pSma
,
SRSmaInfo
*
pInfo
,
bool
isDeepFree
);
int32_t
tdRSmaFSOpen
(
SSma
*
pSma
,
int64_t
version
,
int8_t
rollback
);
...
...
source/dnode/vnode/src/sma/smaCommit.c
浏览文件 @
1fb2df03
...
...
@@ -17,18 +17,26 @@
extern
SSmaMgmt
smaMgmt
;
static
int32_t
tdProcessRSmaAsyncPreCommitImpl
(
SSma
*
pSma
);
static
int32_t
tdProcessRSmaAsyncPreCommitImpl
(
SSma
*
pSma
,
bool
isCommit
);
static
int32_t
tdProcessRSmaAsyncCommitImpl
(
SSma
*
pSma
,
SCommitInfo
*
pInfo
);
static
int32_t
tdProcessRSmaAsyncPostCommitImpl
(
SSma
*
pSma
);
static
int32_t
tdUpdateQTaskInfoFiles
(
SSma
*
pSma
,
SRSmaStat
*
pRSmaStat
);
/**
* @brief only applicable to Rollup SMA
*
* @param pSma
* @return int32_t
*/
int32_t
smaPreClose
(
SSma
*
pSma
)
{
return
tdProcessRSmaAsyncPreCommitImpl
(
pSma
,
false
);
}
/**
* @brief async commit, only applicable to Rollup SMA
*
* @param pSma
* @return int32_t
*/
int32_t
smaPrepareAsyncCommit
(
SSma
*
pSma
)
{
return
tdProcessRSmaAsyncPreCommitImpl
(
pSma
);
}
int32_t
smaPrepareAsyncCommit
(
SSma
*
pSma
)
{
return
tdProcessRSmaAsyncPreCommitImpl
(
pSma
,
true
);
}
/**
* @brief async commit, only applicable to Rollup SMA
...
...
@@ -124,7 +132,7 @@ _exit:
* @param pSma
* @return int32_t
*/
static
int32_t
tdProcessRSmaAsyncPreCommitImpl
(
SSma
*
pSma
)
{
static
int32_t
tdProcessRSmaAsyncPreCommitImpl
(
SSma
*
pSma
,
bool
isCommit
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -139,15 +147,18 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
// step 1: set rsma stat
atomic_store_8
(
RSMA_TRIGGER_STAT
(
pRSmaStat
),
TASK_TRIGGER_STAT_PAUSED
);
while
(
atomic_val_compare_exchange_8
(
RSMA_COMMIT_STAT
(
pRSmaStat
),
0
,
1
)
!=
0
)
{
++
nLoops
;
if
(
nLoops
>
1000
)
{
sched_yield
();
nLoops
=
0
;
if
(
isCommit
)
{
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
;
if
(
ASSERTS
(
pRSmaStat
->
commitAppliedVer
>=
0
,
"commit applied version %"
PRIi64
" < 0"
,
if
(
ASSERTS
(
pRSmaStat
->
commitAppliedVer
>=
-
1
,
"commit applied version %"
PRIi64
" < 0"
,
pRSmaStat
->
commitAppliedVer
))
{
code
=
TSDB_CODE_APP_ERROR
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
@@ -156,7 +167,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
// step 2: wait for all triggered fetch tasks to finish
nLoops
=
0
;
while
(
1
)
{
if
(
T_REF_VAL_GET
(
pStat
)
=
=
0
)
{
if
(
atomic_load_32
(
&
pRSmaStat
->
nFetchAll
)
<
=
0
)
{
smaDebug
(
"vgId:%d, rsma commit, fetch tasks are all finished"
,
SMA_VID
(
pSma
));
break
;
}
else
{
...
...
@@ -184,6 +195,9 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
nLoops
=
0
;
}
}
if
(
!
isCommit
)
goto
_exit
;
smaInfo
(
"vgId:%d, rsma commit, all items are consumed, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
code
=
tdRSmaPersistExecImpl
(
pRSmaStat
,
RSMA_INFO_HASH
(
pRSmaStat
));
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
1fb2df03
...
...
@@ -167,6 +167,7 @@ _exit:
int32_t
smaClose
(
SSma
*
pSma
)
{
if
(
pSma
)
{
smaPreClose
(
pSma
);
taosThreadMutexDestroy
(
&
pSma
->
mutex
);
SMA_TSMA_ENV
(
pSma
)
=
tdFreeSmaEnv
(
SMA_TSMA_ENV
(
pSma
));
SMA_RSMA_ENV
(
pSma
)
=
tdFreeSmaEnv
(
SMA_RSMA_ENV
(
pSma
));
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
1fb2df03
...
...
@@ -296,12 +296,6 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
tsem_wait
(
&
pVnode
->
canCommit
);
taosThreadMutexLock
(
&
pVnode
->
mutex
);
ASSERT
(
pVnode
->
onCommit
==
NULL
);
pVnode
->
onCommit
=
pVnode
->
inUse
;
pVnode
->
inUse
=
NULL
;
taosThreadMutexUnlock
(
&
pVnode
->
mutex
);
pVnode
->
state
.
commitTerm
=
pVnode
->
state
.
applyTerm
;
pInfo
->
info
.
config
=
pVnode
->
config
;
...
...
@@ -331,6 +325,12 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) {
code
=
smaPrepareAsyncCommit
(
pVnode
->
pSma
);
if
(
code
)
goto
_exit
;
taosThreadMutexLock
(
&
pVnode
->
mutex
);
ASSERT
(
pVnode
->
onCommit
==
NULL
);
pVnode
->
onCommit
=
pVnode
->
inUse
;
pVnode
->
inUse
=
NULL
;
taosThreadMutexUnlock
(
&
pVnode
->
mutex
);
_exit:
if
(
code
)
{
vError
(
"vgId:%d, %s failed at line %d since %s, commit id:%"
PRId64
,
TD_VID
(
pVnode
),
__func__
,
lino
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录