Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2b2e1c79
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2b2e1c79
编写于
8月 01, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: write snapshot after apply queue is empty
上级
99f29f64
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
6 deletion
+27
-6
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+27
-6
未找到文件。
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
2b2e1c79
...
...
@@ -30,6 +30,7 @@ static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
if
(
vnodeIsMsgBlock
(
pMsg
->
msgType
))
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
vGTrace
(
"vgId:%d, msg:%p wait block, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
pVnode
->
blockCount
=
1
;
tsem_wait
(
&
pVnode
->
syncSem
);
}
}
...
...
@@ -37,9 +38,12 @@ static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
static
inline
void
vnodePostBlockMsg
(
SVnode
*
pVnode
,
const
SRpcMsg
*
pMsg
)
{
if
(
vnodeIsMsgBlock
(
pMsg
->
msgType
))
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
if
(
pVnode
->
blockCount
)
{
vGTrace
(
"vgId:%d, msg:%p post block, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
pVnode
->
blockCount
=
0
;
tsem_post
(
&
pVnode
->
syncSem
);
}
}
}
static
int32_t
vnodeSetStandBy
(
SVnode
*
pVnode
)
{
...
...
@@ -281,14 +285,15 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
vG
Info
(
"vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%ld"
,
vgId
,
pMsg
,
vG
Trace
(
"vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%"
PRId64
,
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
info
.
handle
,
pMsg
->
info
.
conn
.
applyIndex
);
SRpcMsg
rsp
=
{.
code
=
pMsg
->
code
,
.
info
=
pMsg
->
info
};
if
(
rsp
.
code
==
0
)
{
if
(
vnodeProcessWriteMsg
(
pVnode
,
pMsg
,
pMsg
->
info
.
conn
.
applyIndex
,
&
rsp
)
<
0
)
{
rsp
.
code
=
terrno
;
vError
(
"vgId:%d, msg:%p failed to apply since %s"
,
vgId
,
pMsg
,
terrstr
());
vGError
(
"vgId:%d, msg:%p failed to apply since %s, index:%"
PRId64
,
vgId
,
pMsg
,
terrstr
(),
pMsg
->
info
.
conn
.
applyIndex
);
}
}
...
...
@@ -297,7 +302,7 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
tmsgSendRsp
(
&
rsp
);
}
vGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x
"
,
vgId
,
pMsg
,
rsp
.
code
);
vGTrace
(
"vgId:%d, msg:%p is freed, code:0x%x
index:%"
PRId64
,
vgId
,
pMsg
,
rsp
.
code
,
pMsg
->
info
.
conn
.
applyIndex
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
...
...
@@ -611,6 +616,18 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
#ifdef USE_TSDB_SNAPSHOT
SVnode
*
pVnode
=
pFsm
->
data
;
SSnapshotParam
*
pSnapshotParam
=
pParam
;
do
{
int32_t
itemSize
=
tmsgGetQueueSize
(
&
pVnode
->
msgCb
,
pVnode
->
config
.
vgId
,
APPLY_QUEUE
);
if
(
itemSize
==
0
)
{
vDebug
(
"vgId:%d, apply queue is empty, start write snapshot"
,
pVnode
->
config
.
vgId
);
break
;
}
else
{
vDebug
(
"vgId:%d, %d items in apply queue, write snapshot later"
,
pVnode
->
config
.
vgId
);
taosMsleep
(
10
);
}
}
while
(
true
);
int32_t
code
=
vnodeSnapWriterOpen
(
pVnode
,
pSnapshotParam
->
start
,
pSnapshotParam
->
end
,
(
SVSnapWriter
**
)
ppWriter
);
return
code
;
#else
...
...
@@ -622,7 +639,10 @@ static int32_t vnodeSnapshotStartWrite(struct SSyncFSM *pFsm, void *pParam, void
static
int32_t
vnodeSnapshotStopWrite
(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
bool
isApply
,
SSnapshot
*
pSnapshot
)
{
#ifdef USE_TSDB_SNAPSHOT
SVnode
*
pVnode
=
pFsm
->
data
;
vDebug
(
"vgId:%d, stop write snapshot, isApply:%d"
,
pVnode
->
config
.
vgId
,
isApply
);
int32_t
code
=
vnodeSnapWriterClose
(
pWriter
,
!
isApply
,
pSnapshot
);
vDebug
(
"vgId:%d, apply snapshot to vnode, code:0x%x"
,
pVnode
->
config
.
vgId
,
code
);
return
code
;
#else
taosMemoryFree
(
pWriter
);
...
...
@@ -634,6 +654,7 @@ static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void *
#ifdef USE_TSDB_SNAPSHOT
SVnode
*
pVnode
=
pFsm
->
data
;
int32_t
code
=
vnodeSnapWrite
(
pWriter
,
pBuf
,
len
);
vTrace
(
"vgId:%d, write snapshot, len:%d"
,
pVnode
->
config
.
vgId
,
len
);
return
code
;
#else
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录