Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
256ae4eb
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看板
未验证
提交
256ae4eb
编写于
2月 07, 2023
作者:
D
dapan1121
提交者:
GitHub
2月 07, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19683 from taosdata/fix/TD-22047-3.0
fix: rsma close and commit refactor
上级
1d483fd5
8df67a9a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
29 deletion
+46
-29
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
+36
-22
source/dnode/vnode/src/sma/smaOpen.c
source/dnode/vnode/src/sma/smaOpen.c
+1
-0
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+1
-1
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+6
-6
未找到文件。
source/dnode/vnode/src/inc/sma.h
浏览文件 @
256ae4eb
...
...
@@ -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
浏览文件 @
256ae4eb
...
...
@@ -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
...
...
@@ -122,9 +130,10 @@ _exit:
* 2) Wait all running fetch task finish to fetch and put submitMsg into level 2/3 wQueue(blocking level 1 write)
*
* @param pSma
* @param isCommit
* @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,28 +148,30 @@ 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"
,
pRSmaStat
->
commitAppliedVer
))
{
code
=
TSDB_CODE_APP_ERROR
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
pRSmaStat
->
commitAppliedVer
=
pSma
->
pVnode
->
state
.
applied
;
if
(
ASSERTS
(
pRSmaStat
->
commitAppliedVer
>=
-
1
,
"commit applied version %"
PRIi64
" < -1"
,
pRSmaStat
->
commitAppliedVer
))
{
code
=
TSDB_CODE_APP_ERROR
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
// step 2: wait for all triggered fetch tasks to finish
nLoops
=
0
;
while
(
1
)
{
if
(
T_REF_VAL_GET
(
pStat
)
=
=
0
)
{
smaDebug
(
"vgId:%d, rsma commit
, fetch tasks are all finished"
,
SMA_VID
(
pSma
)
);
if
(
atomic_load_32
(
&
pRSmaStat
->
nFetchAll
)
<
=
0
)
{
smaDebug
(
"vgId:%d, rsma commit
:%d, fetch tasks are all finished"
,
SMA_VID
(
pSma
),
isCommit
);
break
;
}
else
{
smaDebug
(
"vgId:%d, rsma commit
, fetch tasks are not all finished yet"
,
SMA_VID
(
pSma
)
);
smaDebug
(
"vgId:%d, rsma commit
%d, fetch tasks are not all finished yet"
,
SMA_VID
(
pSma
),
isCommit
);
}
++
nLoops
;
if
(
nLoops
>
1000
)
{
...
...
@@ -174,7 +185,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
* 1) This is high cost task and should not put in asyncPreCommit originally.
* 2) But, if put in asyncCommit, would trigger taskInfo cloning frequently.
*/
smaInfo
(
"vgId:%d, rsma commit
, wait for all items to be consumed, TID:%p"
,
SMA_VID
(
pSma
)
,
smaInfo
(
"vgId:%d, rsma commit
:%d, wait for all items to be consumed, TID:%p"
,
SMA_VID
(
pSma
),
isCommit
,
(
void
*
)
taosGetSelfPthreadId
());
nLoops
=
0
;
while
(
atomic_load_64
(
&
pRSmaStat
->
nBufItems
)
>
0
)
{
...
...
@@ -184,10 +195,13 @@ 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
);
smaInfo
(
"vgId:%d, rsma commit, operator state committed, TID:%p"
,
SMA_VID
(
pSma
),
(
void
*
)
taosGetSelfPthreadId
());
#if 0 // consuming task of qTaskInfo clone
...
...
@@ -223,7 +237,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
_exit:
if
(
code
)
{
smaError
(
"vgId:%d, %s failed at line %d since %s
"
,
SMA_VID
(
pSma
),
__func__
,
lino
,
tstrerror
(
code
)
);
smaError
(
"vgId:%d, %s failed at line %d since %s
(%d)"
,
SMA_VID
(
pSma
),
__func__
,
lino
,
tstrerror
(
code
),
isCommit
);
}
return
code
;
}
...
...
@@ -243,7 +257,7 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) {
if
(
!
pSmaEnv
)
{
goto
_exit
;
}
code
=
tdRSmaFSCommit
(
pSma
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/sma/smaOpen.c
浏览文件 @
256ae4eb
...
...
@@ -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/tsdb/tsdbSnapshot.c
浏览文件 @
256ae4eb
...
...
@@ -656,7 +656,7 @@ static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
}
SSnapDataHdr
*
pHdr
=
(
SSnapDataHdr
*
)
*
ppData
;
pHdr
->
type
=
SNAP_DATA_TSDB
;
pHdr
->
type
=
pReader
->
type
;
pHdr
->
size
=
size
;
memcpy
(
pHdr
->
data
,
pReader
->
aBuf
[
3
],
aBufN
[
3
]);
...
...
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
256ae4eb
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录