Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
60bab9ae
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
60bab9ae
编写于
12月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: post sem in vnode while sync timeout
上级
9af36669
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
52 addition
and
35 deletion
+52
-35
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-1
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+26
-25
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+18
-6
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+7
-3
未找到文件。
include/libs/sync/sync.h
浏览文件 @
60bab9ae
...
...
@@ -240,7 +240,7 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm);
bool
syncIsReadyForRead
(
int64_t
rid
);
bool
syncSnapshotSending
(
int64_t
rid
);
bool
syncSnapshotRecving
(
int64_t
rid
);
void
syncSendTimeoutRsp
(
int64_t
rid
,
int64_t
seq
);
int32_t
syncSendTimeoutRsp
(
int64_t
rid
,
int64_t
seq
);
SSyncState
syncGetState
(
int64_t
rid
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
60bab9ae
...
...
@@ -322,31 +322,32 @@ struct STsdbKeepCfg {
};
struct
SVnode
{
char
*
path
;
SVnodeCfg
config
;
SVState
state
;
SVStatis
statis
;
STfs
*
pTfs
;
SMsgCb
msgCb
;
TdThreadMutex
mutex
;
TdThreadCond
poolNotEmpty
;
SVBufPool
*
pPool
;
SVBufPool
*
inUse
;
SMeta
*
pMeta
;
SSma
*
pSma
;
STsdb
*
pTsdb
;
SWal
*
pWal
;
STQ
*
pTq
;
SSink
*
pSink
;
tsem_t
canCommit
;
int64_t
sync
;
TdThreadMutex
lock
;
bool
blocked
;
bool
restored
;
tsem_t
syncSem
;
int32_t
blockSec
;
int64_t
blockSeq
;
SQHandle
*
pQuery
;
char
*
path
;
SVnodeCfg
config
;
SVState
state
;
SVStatis
statis
;
STfs
*
pTfs
;
SMsgCb
msgCb
;
TdThreadMutex
mutex
;
TdThreadCond
poolNotEmpty
;
SVBufPool
*
pPool
;
SVBufPool
*
inUse
;
SMeta
*
pMeta
;
SSma
*
pSma
;
STsdb
*
pTsdb
;
SWal
*
pWal
;
STQ
*
pTq
;
SSink
*
pSink
;
tsem_t
canCommit
;
int64_t
sync
;
TdThreadMutex
lock
;
bool
blocked
;
bool
restored
;
tsem_t
syncSem
;
int32_t
blockSec
;
int64_t
blockSeq
;
SRpcHandleInfo
blockInfo
;
SQHandle
*
pQuery
;
};
#define TD_VID(PVNODE) ((PVNODE)->config.vgId)
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
60bab9ae
...
...
@@ -32,8 +32,11 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) {
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
taosThreadMutexLock
(
&
pVnode
->
lock
);
if
(
pVnode
->
blocked
)
{
vGTrace
(
"vgId:%d, msg:%p post block, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
vGTrace
(
"vgId:%d, msg:%p post block, type:%s sec:%d seq:%"
PRId64
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
pVnode
->
blockSec
,
pVnode
->
blockSeq
);
pVnode
->
blocked
=
false
;
pVnode
->
blockSec
=
0
;
pVnode
->
blockSeq
=
0
;
tsem_post
(
&
pVnode
->
syncSem
);
}
taosThreadMutexUnlock
(
&
pVnode
->
lock
);
...
...
@@ -213,6 +216,7 @@ static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak
pVnode
->
blocked
=
true
;
pVnode
->
blockSec
=
taosGetTimestampSec
();
pVnode
->
blockSeq
=
seq
;
pVnode
->
blockInfo
=
pMsg
->
info
;
}
taosThreadMutexUnlock
(
&
pVnode
->
lock
);
...
...
@@ -279,12 +283,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
;
vGTrace
(
"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
);
if
(
vnodeIsMsgBlock
(
pMsg
->
msgType
))
{
vTrace
(
"vgId:%d, blocking msg obtained from apply-queue. index:%"
PRId64
", term: %"
PRId64
", type: %s"
,
vgId
,
pMsg
->
info
.
conn
.
applyIndex
,
pMsg
->
info
.
conn
.
applyTerm
,
TMSG_INFO
(
pMsg
->
msgType
));
vGTrace
(
"vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%"
PRId64
", blocking msg obtained sec:%d seq:%"
PRId64
,
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
pMsg
->
info
.
handle
,
pMsg
->
info
.
conn
.
applyIndex
,
pVnode
->
blockSec
,
pVnode
->
blockSeq
);
}
else
{
vGTrace
(
"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
};
...
...
@@ -618,9 +625,14 @@ void vnodeSyncCheckTimeout(SVnode *pVnode) {
int32_t
curSec
=
taosGetTimestampSec
();
int32_t
delta
=
curSec
-
pVnode
->
blockSec
;
if
(
delta
>
VNODE_TIMEOUT_SEC
)
{
syncSendTimeoutRsp
(
pVnode
->
sync
,
pVnode
->
blockSeq
);
vError
(
"vgId:%d, failed to propose since timeout and post block, start:%d cur:%d delta:%d seq:%"
PRId64
,
pVnode
->
config
.
vgId
,
pVnode
->
blockSec
,
curSec
,
delta
,
pVnode
->
blockSeq
);
if
(
syncSendTimeoutRsp
(
pVnode
->
sync
,
pVnode
->
blockSeq
)
!=
0
)
{
SRpcMsg
rpcMsg
=
{.
code
=
TSDB_CODE_SYN_TIMEOUT
,
.
info
=
pVnode
->
blockInfo
};
vInfo
(
"send timeout response since its applyed, seq:%"
PRId64
" handle:%p ahandle:%p"
,
pVnode
->
blockSeq
,
rpcMsg
.
info
.
handle
,
rpcMsg
.
info
.
ahandle
);
rpcSendResponse
(
&
rpcMsg
);
}
pVnode
->
blocked
=
false
;
pVnode
->
blockSec
=
0
;
pVnode
->
blockSeq
=
0
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
60bab9ae
...
...
@@ -218,9 +218,9 @@ int32_t syncLeaderTransfer(int64_t rid) {
return
ret
;
}
void
syncSendTimeoutRsp
(
int64_t
rid
,
int64_t
seq
)
{
int32_t
syncSendTimeoutRsp
(
int64_t
rid
,
int64_t
seq
)
{
SSyncNode
*
pNode
=
syncNodeAcquire
(
rid
);
if
(
pNode
==
NULL
)
return
;
if
(
pNode
==
NULL
)
return
-
1
;
SRpcMsg
rpcMsg
=
{
0
};
int32_t
ret
=
syncRespMgrGetAndDel
(
pNode
->
pSyncRespMgr
,
seq
,
&
rpcMsg
.
info
);
...
...
@@ -228,9 +228,13 @@ void syncSendTimeoutRsp(int64_t rid, int64_t seq) {
syncNodeRelease
(
pNode
);
if
(
ret
==
1
)
{
sInfo
(
"send
response since sync timeout
, seq:%"
PRId64
" handle:%p ahandle:%p"
,
seq
,
rpcMsg
.
info
.
handle
,
sInfo
(
"send
timeout response
, seq:%"
PRId64
" handle:%p ahandle:%p"
,
seq
,
rpcMsg
.
info
.
handle
,
rpcMsg
.
info
.
ahandle
);
rpcSendResponse
(
&
rpcMsg
);
return
0
;
}
else
{
sInfo
(
"no rpcinfo to send timeout response, seq:%"
PRId64
,
seq
);
return
-
1
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录