Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eaf56916
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看板
未验证
提交
eaf56916
编写于
3月 29, 2023
作者:
X
Xiaoyu Wang
提交者:
GitHub
3月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20678 from taosdata/FIX/TD-22975-main
enh: separate sync read and write
上级
9992942a
ae8d8764
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
62 addition
and
67 deletion
+62
-67
include/common/tmsgcb.h
include/common/tmsgcb.h
+1
-1
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-1
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
+2
-2
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+7
-5
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+8
-8
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+2
-2
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+6
-5
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+3
-3
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+9
-11
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+1
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-1
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+3
-3
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+0
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+11
-14
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+2
-2
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+4
-1
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+1
-1
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+0
-5
未找到文件。
include/common/tmsgcb.h
浏览文件 @
eaf56916
...
@@ -34,7 +34,7 @@ typedef enum {
...
@@ -34,7 +34,7 @@ typedef enum {
WRITE_QUEUE
,
WRITE_QUEUE
,
APPLY_QUEUE
,
APPLY_QUEUE
,
SYNC_QUEUE
,
SYNC_QUEUE
,
SYNC_
CTRL
_QUEUE
,
SYNC_
RD
_QUEUE
,
STREAM_QUEUE
,
STREAM_QUEUE
,
QUEUE_MAX
,
QUEUE_MAX
,
}
EQueueType
;
}
EQueueType
;
...
...
include/common/tmsgdef.h
浏览文件 @
eaf56916
...
@@ -259,7 +259,7 @@ enum {
...
@@ -259,7 +259,7 @@ enum {
TD_NEW_MSG_SEG
(
TDMT_SYNC_MSG
)
TD_NEW_MSG_SEG
(
TDMT_SYNC_MSG
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_TIMEOUT
,
"sync-timer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_TIMEOUT
,
"sync-timer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_
PING
,
"sync-ping"
,
NULL
,
NULL
)
// no longer used
TD_DEF_MSG_TYPE
(
TDMT_SYNC_
TIMEOUT_ELECTION
,
"sync-elect"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_PING_REPLY
,
"sync-ping-reply"
,
NULL
,
NULL
)
// no longer used
TD_DEF_MSG_TYPE
(
TDMT_SYNC_PING_REPLY
,
"sync-ping-reply"
,
NULL
,
NULL
)
// no longer used
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST
,
"sync-client-request"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST
,
"sync-client-request"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
"sync-client-request-batch"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
"sync-client-request-batch"
,
NULL
,
NULL
)
...
...
source/dnode/mgmt/mgmt_mnode/inc/mmInt.h
浏览文件 @
eaf56916
...
@@ -34,7 +34,7 @@ typedef struct SMnodeMgmt {
...
@@ -34,7 +34,7 @@ typedef struct SMnodeMgmt {
SSingleWorker
readWorker
;
SSingleWorker
readWorker
;
SSingleWorker
writeWorker
;
SSingleWorker
writeWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
syncWorker
;
SSingleWorker
sync
Ctrl
Worker
;
SSingleWorker
sync
Rd
Worker
;
bool
stopped
;
bool
stopped
;
int32_t
refCount
;
int32_t
refCount
;
TdThreadRwlock
lock
;
TdThreadRwlock
lock
;
...
@@ -54,7 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt);
...
@@ -54,7 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
void
mmStopWorker
(
SMnodeMgmt
*
pMgmt
);
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToWriteQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSyncQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSync
Ctrl
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToSync
Rd
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToFetchQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
mmPutMsgToFetchQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
eaf56916
...
@@ -188,7 +188,8 @@ SArray *mmGetMsgHandles() {
...
@@ -188,7 +188,8 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_INDEX_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DROP_INDEX_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DISABLE_WRITE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DISABLE_WRITE_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT_ELECTION
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
...
@@ -198,11 +199,12 @@ SArray *mmGetMsgHandles() {
...
@@ -198,11 +199,12 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_BATCH
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_BATCH
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
mmPutMsgToSyncQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
mmPutMsgToSyncCtrlQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
mmPutMsgToSyncCtrlQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
mmPutMsgToSyncRdQueue
,
1
)
==
NULL
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
eaf56916
...
@@ -111,8 +111,8 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -111,8 +111,8 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
syncWorker
,
pMsg
);
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
syncWorker
,
pMsg
);
}
}
int32_t
mmPutMsgToSync
Ctrl
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToSync
Rd
Queue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
sync
Ctrl
Worker
,
pMsg
);
return
mmPutMsgToWorker
(
pMgmt
,
&
pMgmt
->
sync
Rd
Worker
,
pMsg
);
}
}
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToReadQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
...
@@ -151,8 +151,8 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
...
@@ -151,8 +151,8 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
case
SYNC_QUEUE
:
case
SYNC_QUEUE
:
pWorker
=
&
pMgmt
->
syncWorker
;
pWorker
=
&
pMgmt
->
syncWorker
;
break
;
break
;
case
SYNC_
CTRL
_QUEUE
:
case
SYNC_
RD
_QUEUE
:
pWorker
=
&
pMgmt
->
sync
Ctrl
Worker
;
pWorker
=
&
pMgmt
->
sync
Rd
Worker
;
break
;
break
;
default:
default:
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
...
@@ -238,12 +238,12 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -238,12 +238,12 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
SSingleWorkerCfg
scCfg
=
{
SSingleWorkerCfg
scCfg
=
{
.
min
=
1
,
.
min
=
1
,
.
max
=
1
,
.
max
=
1
,
.
name
=
"mnode-sync-
ctrl
"
,
.
name
=
"mnode-sync-
rd
"
,
.
fp
=
(
FItem
)
mmProcessSyncMsg
,
.
fp
=
(
FItem
)
mmProcessSyncMsg
,
.
param
=
pMgmt
,
.
param
=
pMgmt
,
};
};
if
(
tSingleWorkerInit
(
&
pMgmt
->
sync
Ctrl
Worker
,
&
scCfg
)
!=
0
)
{
if
(
tSingleWorkerInit
(
&
pMgmt
->
sync
Rd
Worker
,
&
scCfg
)
!=
0
)
{
dError
(
"failed to start mnode mnode-sync-
ctrl
worker since %s"
,
terrstr
());
dError
(
"failed to start mnode mnode-sync-
rd
worker since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
@@ -259,6 +259,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
...
@@ -259,6 +259,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
sync
Ctrl
Worker
);
tSingleWorkerCleanup
(
&
pMgmt
->
sync
Rd
Worker
);
dDebug
(
"mnode workers are closed"
);
dDebug
(
"mnode workers are closed"
);
}
}
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
eaf56916
...
@@ -59,7 +59,7 @@ typedef struct {
...
@@ -59,7 +59,7 @@ typedef struct {
SVnode
*
pImpl
;
SVnode
*
pImpl
;
SMultiWorker
pWriteW
;
SMultiWorker
pWriteW
;
SMultiWorker
pSyncW
;
SMultiWorker
pSyncW
;
SMultiWorker
pSync
Ctrl
W
;
SMultiWorker
pSync
Rd
W
;
SMultiWorker
pApplyW
;
SMultiWorker
pApplyW
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pStreamQ
;
STaosQueue
*
pStreamQ
;
...
@@ -107,7 +107,7 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
...
@@ -107,7 +107,7 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToWriteQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSync
Ctrl
Queue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToSync
Rd
Queue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToQueryQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToStreamQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
int32_t
vmPutMsgToStreamQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
eaf56916
...
@@ -549,7 +549,8 @@ SArray *vmGetMsgHandles() {
...
@@ -549,7 +549,8 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_CREATE_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_DND_DROP_VNODE
,
vmPutMsgToMgmtQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT_ELECTION
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
@@ -559,12 +560,12 @@ SArray *vmGetMsgHandles() {
...
@@ -559,12 +560,12 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_BATCH
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_BATCH
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_APPEND_ENTRIES_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_SEND
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
vmPutMsgToSyncQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT
,
vmPutMsgToSyncCtrlQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_TIMEOUT
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
vmPutMsgToSyncCtrlQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_HEARTBEAT_REPLY
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_SNAPSHOT_RSP
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_SYNC_PRE_SNAPSHOT_REPLY
,
vmPutMsgToSyncRdQueue
,
0
)
==
NULL
)
goto
_OVER
;
code
=
0
;
code
=
0
;
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
eaf56916
...
@@ -98,9 +98,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal)
...
@@ -98,9 +98,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal)
pVnode
->
pSyncW
.
queue
->
threadId
);
pVnode
->
pSyncW
.
queue
->
threadId
);
tMultiWorkerCleanup
(
&
pVnode
->
pSyncW
);
tMultiWorkerCleanup
(
&
pVnode
->
pSyncW
);
dInfo
(
"vgId:%d, wait for vnode sync
ctrl queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
dInfo
(
"vgId:%d, wait for vnode sync
rd queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncRdW
.
queue
,
pVnode
->
pSync
CtrlW
.
queue
,
pVnode
->
pSyncCtrl
W
.
queue
->
threadId
);
pVnode
->
pSync
Rd
W
.
queue
->
threadId
);
tMultiWorkerCleanup
(
&
pVnode
->
pSync
Ctrl
W
);
tMultiWorkerCleanup
(
&
pVnode
->
pSync
Rd
W
);
dInfo
(
"vgId:%d, wait for vnode apply queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pApplyW
.
queue
,
dInfo
(
"vgId:%d, wait for vnode apply queue:%p is empty, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pApplyW
.
queue
,
pVnode
->
pApplyW
.
queue
->
threadId
);
pVnode
->
pApplyW
.
queue
->
threadId
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
eaf56916
...
@@ -216,9 +216,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -216,9 +216,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSyncW
.
queue
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSyncW
.
queue
,
pMsg
);
break
;
break
;
case
SYNC_
CTRL
_QUEUE
:
case
SYNC_
RD
_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync-
ctrl
queue"
,
pVnode
->
vgId
,
pMsg
);
dGTrace
(
"vgId:%d, msg:%p put into vnode-sync-
rd
queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSync
Ctrl
W
.
queue
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSync
Rd
W
.
queue
,
pMsg
);
break
;
break
;
case
APPLY_QUEUE
:
case
APPLY_QUEUE
:
dGTrace
(
"vgId:%d, msg:%p put into vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
dGTrace
(
"vgId:%d, msg:%p put into vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
...
@@ -234,9 +234,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -234,9 +234,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
return
code
;
return
code
;
}
}
int32_t
vmPutMsgToSyncCtrlQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
vmPutMsgToSyncRdQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_RD_QUEUE
);
}
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_CTRL_QUEUE
);
}
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
int32_t
vmPutMsgToSyncQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
SYNC_QUEUE
);
}
...
@@ -327,18 +325,18 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
...
@@ -327,18 +325,18 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
int32_t
vmAllocQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
int32_t
vmAllocQueue
(
SVnodeMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
SMultiWorkerCfg
wcfg
=
{.
max
=
1
,
.
name
=
"vnode-write"
,
.
fp
=
(
FItems
)
vnodeProposeWriteMsg
,
.
param
=
pVnode
->
pImpl
};
SMultiWorkerCfg
wcfg
=
{.
max
=
1
,
.
name
=
"vnode-write"
,
.
fp
=
(
FItems
)
vnodeProposeWriteMsg
,
.
param
=
pVnode
->
pImpl
};
SMultiWorkerCfg
scfg
=
{.
max
=
1
,
.
name
=
"vnode-sync"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
scfg
=
{.
max
=
1
,
.
name
=
"vnode-sync"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
sccfg
=
{.
max
=
1
,
.
name
=
"vnode-sync-
ctrl
"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
sccfg
=
{.
max
=
1
,
.
name
=
"vnode-sync-
rd
"
,
.
fp
=
(
FItems
)
vmProcessSyncQueue
,
.
param
=
pVnode
};
SMultiWorkerCfg
acfg
=
{.
max
=
1
,
.
name
=
"vnode-apply"
,
.
fp
=
(
FItems
)
vnodeApplyWriteMsg
,
.
param
=
pVnode
->
pImpl
};
SMultiWorkerCfg
acfg
=
{.
max
=
1
,
.
name
=
"vnode-apply"
,
.
fp
=
(
FItems
)
vnodeApplyWriteMsg
,
.
param
=
pVnode
->
pImpl
};
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pWriteW
,
&
wcfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pWriteW
,
&
wcfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSyncW
,
&
scfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSyncW
,
&
scfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSync
Ctrl
W
,
&
sccfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pSync
Rd
W
,
&
sccfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pApplyW
,
&
acfg
);
(
void
)
tMultiWorkerInit
(
&
pVnode
->
pApplyW
,
&
acfg
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pStreamQ
=
tAutoQWorkerAllocQueue
(
&
pMgmt
->
streamPool
,
pVnode
,
(
FItem
)
vmProcessStreamQueue
);
pVnode
->
pStreamQ
=
tAutoQWorkerAllocQueue
(
&
pMgmt
->
streamPool
,
pVnode
,
(
FItem
)
vmProcessStreamQueue
);
pVnode
->
pFetchQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItems
)
vmProcessFetchQueue
);
pVnode
->
pFetchQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItems
)
vmProcessFetchQueue
);
if
(
pVnode
->
pWriteW
.
queue
==
NULL
||
pVnode
->
pSyncW
.
queue
==
NULL
||
pVnode
->
pSync
Ctrl
W
.
queue
==
NULL
||
if
(
pVnode
->
pWriteW
.
queue
==
NULL
||
pVnode
->
pSyncW
.
queue
==
NULL
||
pVnode
->
pSync
Rd
W
.
queue
==
NULL
||
pVnode
->
pApplyW
.
queue
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
pVnode
->
pStreamQ
==
NULL
||
pVnode
->
pFetchQ
==
NULL
)
{
pVnode
->
pApplyW
.
queue
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
pVnode
->
pStreamQ
==
NULL
||
pVnode
->
pFetchQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -348,8 +346,8 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -348,8 +346,8 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
pVnode
->
pWriteW
.
queue
->
threadId
);
pVnode
->
pWriteW
.
queue
->
threadId
);
dInfo
(
"vgId:%d, sync-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncW
.
queue
,
dInfo
(
"vgId:%d, sync-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncW
.
queue
,
pVnode
->
pSyncW
.
queue
->
threadId
);
pVnode
->
pSyncW
.
queue
->
threadId
);
dInfo
(
"vgId:%d, sync-
ctrl-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncCtrl
W
.
queue
,
dInfo
(
"vgId:%d, sync-
rd-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pSyncRd
W
.
queue
,
pVnode
->
pSync
Ctrl
W
.
queue
->
threadId
);
pVnode
->
pSync
Rd
W
.
queue
->
threadId
);
dInfo
(
"vgId:%d, apply-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pApplyW
.
queue
,
dInfo
(
"vgId:%d, apply-queue:%p is alloced, thread:%08"
PRId64
,
pVnode
->
vgId
,
pVnode
->
pApplyW
.
queue
,
pVnode
->
pApplyW
.
queue
->
threadId
);
pVnode
->
pApplyW
.
queue
->
threadId
);
dInfo
(
"vgId:%d, query-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pQueryQ
);
dInfo
(
"vgId:%d, query-queue:%p is alloced"
,
pVnode
->
vgId
,
pVnode
->
pQueryQ
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
eaf56916
...
@@ -33,7 +33,7 @@ static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
...
@@ -33,7 +33,7 @@ static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_
CTRL
_QUEUE
,
pMsg
);
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_
RD
_QUEUE
,
pMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
pMsg
->
pCont
=
NULL
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
eaf56916
...
@@ -378,7 +378,7 @@ static int32_t vnodeSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
...
@@ -378,7 +378,7 @@ static int32_t vnodeSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_
CTRL
_QUEUE
,
pMsg
);
int32_t
code
=
tmsgPutToQueue
(
msgcb
,
SYNC_
RD
_QUEUE
,
pMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
pMsg
->
pCont
=
NULL
;
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
eaf56916
...
@@ -105,6 +105,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -105,6 +105,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
SRpcMsg
rpcRsp
=
{
0
};
SRpcMsg
rpcRsp
=
{
0
};
bool
accepted
=
false
;
bool
accepted
=
false
;
SSyncRaftEntry
*
pEntry
=
NULL
;
SSyncRaftEntry
*
pEntry
=
NULL
;
bool
resetElect
=
false
;
// if already drop replica, do not process
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
)))
{
if
(
!
syncNodeInRaftGroup
(
ths
,
&
(
pMsg
->
srcId
)))
{
...
@@ -137,7 +138,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -137,7 +138,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
}
}
syncNodeStepDown
(
ths
,
pMsg
->
term
);
syncNodeStepDown
(
ths
,
pMsg
->
term
);
syncNodeResetElectTimer
(
ths
)
;
resetElect
=
true
;
if
(
pMsg
->
dataLen
<
sizeof
(
SSyncRaftEntry
))
{
if
(
pMsg
->
dataLen
<
sizeof
(
SSyncRaftEntry
))
{
sError
(
"vgId:%d, incomplete append entries received. prev index:%"
PRId64
", term:%"
PRId64
", datalen:%d"
,
sError
(
"vgId:%d, incomplete append entries received. prev index:%"
PRId64
", term:%"
PRId64
", datalen:%d"
,
...
@@ -184,10 +185,9 @@ _SEND_RESPONSE:
...
@@ -184,10 +185,9 @@ _SEND_RESPONSE:
// commit index, i.e. leader notice me
// commit index, i.e. leader notice me
if
(
syncLogBufferCommit
(
ths
->
pLogBuf
,
ths
,
ths
->
commitIndex
)
<
0
)
{
if
(
syncLogBufferCommit
(
ths
->
pLogBuf
,
ths
,
ths
->
commitIndex
)
<
0
)
{
sError
(
"vgId:%d, failed to commit raft fsm log since %s."
,
ths
->
vgId
,
terrstr
());
sError
(
"vgId:%d, failed to commit raft fsm log since %s."
,
ths
->
vgId
,
terrstr
());
goto
_out
;
}
}
_out:
if
(
resetElect
)
syncNodeResetElectTimer
(
ths
);
return
0
;
return
0
;
_IGNORE:
_IGNORE:
...
...
source/libs/sync/src/syncElection.c
浏览文件 @
eaf56916
...
@@ -115,6 +115,5 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
...
@@ -115,6 +115,5 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) {
ASSERT
(
ret
==
0
);
ASSERT
(
ret
==
0
);
syncNodeResetElectTimer
(
pSyncNode
);
syncNodeResetElectTimer
(
pSyncNode
);
return
ret
;
return
ret
;
}
}
source/libs/sync/src/syncMain.c
浏览文件 @
eaf56916
...
@@ -182,6 +182,9 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) {
...
@@ -182,6 +182,9 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) {
case
TDMT_SYNC_TIMEOUT
:
case
TDMT_SYNC_TIMEOUT
:
code
=
syncNodeOnTimeout
(
pSyncNode
,
pMsg
);
code
=
syncNodeOnTimeout
(
pSyncNode
,
pMsg
);
break
;
break
;
case
TDMT_SYNC_TIMEOUT_ELECTION
:
code
=
syncNodeOnTimeout
(
pSyncNode
,
pMsg
);
break
;
case
TDMT_SYNC_CLIENT_REQUEST
:
case
TDMT_SYNC_CLIENT_REQUEST
:
code
=
syncNodeOnClientRequest
(
pSyncNode
,
pMsg
,
NULL
);
code
=
syncNodeOnClientRequest
(
pSyncNode
,
pMsg
,
NULL
);
break
;
break
;
...
@@ -1593,8 +1596,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
...
@@ -1593,8 +1596,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
pSyncNode
->
state
=
TAOS_SYNC_STATE_FOLLOWER
;
pSyncNode
->
state
=
TAOS_SYNC_STATE_FOLLOWER
;
syncNodeStopHeartbeatTimer
(
pSyncNode
);
syncNodeStopHeartbeatTimer
(
pSyncNode
);
//
reset elect timer
//
trace log
s
yncNodeResetElectTimer
(
pSyncNode
);
s
NTrace
(
pSyncNode
,
"become follower %s"
,
debugStr
);
// send rsp to client
// send rsp to client
syncNodeLeaderChangeRsp
(
pSyncNode
);
syncNodeLeaderChangeRsp
(
pSyncNode
);
...
@@ -1610,8 +1613,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
...
@@ -1610,8 +1613,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
// reset log buffer
// reset log buffer
syncLogBufferReset
(
pSyncNode
->
pLogBuf
,
pSyncNode
);
syncLogBufferReset
(
pSyncNode
->
pLogBuf
,
pSyncNode
);
//
trace log
//
reset elect timer
s
NTrace
(
pSyncNode
,
"become follower %s"
,
debugStr
);
s
yncNodeResetElectTimer
(
pSyncNode
);
}
}
// TLA+ Spec
// TLA+ Spec
...
@@ -2277,6 +2280,7 @@ static int32_t syncNodeAppendNoopOld(SSyncNode* ths) {
...
@@ -2277,6 +2280,7 @@ static int32_t syncNodeAppendNoopOld(SSyncNode* ths) {
int32_t
syncNodeOnHeartbeat
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
int32_t
syncNodeOnHeartbeat
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
SyncHeartbeat
*
pMsg
=
pRpcMsg
->
pCont
;
SyncHeartbeat
*
pMsg
=
pRpcMsg
->
pCont
;
bool
resetElect
=
false
;
const
STraceId
*
trace
=
&
pRpcMsg
->
info
.
traceId
;
const
STraceId
*
trace
=
&
pRpcMsg
->
info
.
traceId
;
char
tbuf
[
40
]
=
{
0
};
char
tbuf
[
40
]
=
{
0
};
...
@@ -2300,12 +2304,11 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -2300,12 +2304,11 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
if
(
pMsg
->
term
==
currentTerm
&&
ths
->
state
!=
TAOS_SYNC_STATE_LEADER
)
{
if
(
pMsg
->
term
==
currentTerm
&&
ths
->
state
!=
TAOS_SYNC_STATE_LEADER
)
{
syncIndexMgrSetRecvTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
tsMs
);
syncIndexMgrSetRecvTime
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
),
tsMs
);
resetElect
=
true
;
syncNodeResetElectTimer
(
ths
);
ths
->
minMatchIndex
=
pMsg
->
minMatchIndex
;
ths
->
minMatchIndex
=
pMsg
->
minMatchIndex
;
if
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
{
if
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
{
// syncNodeFollowerCommit(ths, pMsg->commitIndex);
SRpcMsg
rpcMsgLocalCmd
=
{
0
};
SRpcMsg
rpcMsgLocalCmd
=
{
0
};
(
void
)
syncBuildLocalCmd
(
&
rpcMsgLocalCmd
,
ths
->
vgId
);
(
void
)
syncBuildLocalCmd
(
&
rpcMsgLocalCmd
,
ths
->
vgId
);
...
@@ -2328,7 +2331,6 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -2328,7 +2331,6 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
}
}
if
(
pMsg
->
term
>=
currentTerm
&&
ths
->
state
!=
TAOS_SYNC_STATE_FOLLOWER
)
{
if
(
pMsg
->
term
>=
currentTerm
&&
ths
->
state
!=
TAOS_SYNC_STATE_FOLLOWER
)
{
// syncNodeStepDown(ths, pMsg->term);
SRpcMsg
rpcMsgLocalCmd
=
{
0
};
SRpcMsg
rpcMsgLocalCmd
=
{
0
};
(
void
)
syncBuildLocalCmd
(
&
rpcMsgLocalCmd
,
ths
->
vgId
);
(
void
)
syncBuildLocalCmd
(
&
rpcMsgLocalCmd
,
ths
->
vgId
);
...
@@ -2348,15 +2350,10 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -2348,15 +2350,10 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
}
}
}
}
/*
// htonl
SMsgHead* pHead = rpcMsg.pCont;
pHead->contLen = htonl(pHead->contLen);
pHead->vgId = htonl(pHead->vgId);
*/
// reply
// reply
syncNodeSendMsgById
(
&
pMsgReply
->
destId
,
ths
,
&
rpcMsg
);
syncNodeSendMsgById
(
&
pMsgReply
->
destId
,
ths
,
&
rpcMsg
);
if
(
resetElect
)
syncNodeResetElectTimer
(
ths
);
return
0
;
return
0
;
}
}
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
eaf56916
...
@@ -22,7 +22,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l
...
@@ -22,7 +22,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l
SSyncNode
*
pNode
)
{
SSyncNode
*
pNode
)
{
int32_t
bytes
=
sizeof
(
SyncTimeout
);
int32_t
bytes
=
sizeof
(
SyncTimeout
);
pMsg
->
pCont
=
rpcMallocCont
(
bytes
);
pMsg
->
pCont
=
rpcMallocCont
(
bytes
);
pMsg
->
msgType
=
TDMT_SYNC_TIMEOUT
;
pMsg
->
msgType
=
(
timeoutType
==
SYNC_TIMEOUT_ELECTION
)
?
TDMT_SYNC_TIMEOUT_ELECTION
:
TDMT_SYNC_TIMEOUT
;
pMsg
->
contLen
=
bytes
;
pMsg
->
contLen
=
bytes
;
if
(
pMsg
->
pCont
==
NULL
)
{
if
(
pMsg
->
pCont
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -31,7 +31,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l
...
@@ -31,7 +31,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l
SyncTimeout
*
pTimeout
=
pMsg
->
pCont
;
SyncTimeout
*
pTimeout
=
pMsg
->
pCont
;
pTimeout
->
bytes
=
bytes
;
pTimeout
->
bytes
=
bytes
;
pTimeout
->
msgType
=
TDMT_SYNC_TIMEOUT
;
pTimeout
->
msgType
=
pMsg
->
msgType
;
pTimeout
->
vgId
=
pNode
->
vgId
;
pTimeout
->
vgId
=
pNode
->
vgId
;
pTimeout
->
timeoutType
=
timeoutType
;
pTimeout
->
timeoutType
=
timeoutType
;
pTimeout
->
logicClock
=
logicClock
;
pTimeout
->
logicClock
=
logicClock
;
...
...
source/libs/sync/src/syncRequestVote.c
浏览文件 @
eaf56916
...
@@ -89,6 +89,7 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* ths, SyncRequestVote* pMsg) {
...
@@ -89,6 +89,7 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* ths, SyncRequestVote* pMsg) {
int32_t
syncNodeOnRequestVote
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
int32_t
syncNodeOnRequestVote
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpcMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
SyncRequestVote
*
pMsg
=
pRpcMsg
->
pCont
;
SyncRequestVote
*
pMsg
=
pRpcMsg
->
pCont
;
bool
resetElect
=
false
;
// if already drop replica, do not process
// if already drop replica, do not process
if
(
!
syncNodeInRaftGroup
(
ths
,
&
pMsg
->
srcId
))
{
if
(
!
syncNodeInRaftGroup
(
ths
,
&
pMsg
->
srcId
))
{
...
@@ -115,7 +116,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -115,7 +116,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
syncNodeStepDown
(
ths
,
currentTerm
);
syncNodeStepDown
(
ths
,
currentTerm
);
// forbid elect for this round
// forbid elect for this round
syncNodeResetElectTimer
(
ths
)
;
resetElect
=
true
;
}
}
// send msg
// send msg
...
@@ -134,5 +135,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
...
@@ -134,5 +135,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
syncLogRecvRequestVote
(
ths
,
pMsg
,
pReply
->
voteGranted
,
""
);
syncLogRecvRequestVote
(
ths
,
pMsg
,
pReply
->
voteGranted
,
""
);
syncLogSendRequestVoteReply
(
ths
,
pReply
,
""
);
syncLogSendRequestVoteReply
(
ths
,
pReply
,
""
);
syncNodeSendMsgById
(
&
pReply
->
destId
,
ths
,
&
rpcMsg
);
syncNodeSendMsgById
(
&
pReply
->
destId
,
ths
,
&
rpcMsg
);
if
(
resetElect
)
syncNodeResetElectTimer
(
ths
);
return
0
;
return
0
;
}
}
source/libs/sync/src/syncSnapshot.c
浏览文件 @
eaf56916
...
@@ -798,7 +798,6 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
...
@@ -798,7 +798,6 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
if
(
pMsg
->
term
>
raftStoreGetTerm
(
pSyncNode
))
{
if
(
pMsg
->
term
>
raftStoreGetTerm
(
pSyncNode
))
{
syncNodeStepDown
(
pSyncNode
,
pMsg
->
term
);
syncNodeStepDown
(
pSyncNode
,
pMsg
->
term
);
}
}
syncNodeResetElectTimer
(
pSyncNode
);
// state, term, seq/ack
// state, term, seq/ack
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -840,6 +839,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
...
@@ -840,6 +839,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) {
code
=
-
1
;
code
=
-
1
;
}
}
syncNodeResetElectTimer
(
pSyncNode
);
return
code
;
return
code
;
}
}
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
eaf56916
...
@@ -120,9 +120,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) {
...
@@ -120,9 +120,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) {
if
(
atomic_load_64
(
&
ths
->
pingTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
if
(
atomic_load_64
(
&
ths
->
pingTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
pingTimerCounter
);
++
(
ths
->
pingTimerCounter
);
// syncNodePingAll(ths);
// syncNodePingPeers(ths);
syncNodeTimerRoutine
(
ths
);
syncNodeTimerRoutine
(
ths
);
}
}
...
@@ -138,8 +135,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) {
...
@@ -138,8 +135,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) {
++
(
ths
->
heartbeatTimerCounter
);
++
(
ths
->
heartbeatTimerCounter
);
sTrace
(
"vgId:%d, sync timer, type:replicate count:%"
PRIu64
", lc-user:%"
PRIu64
,
ths
->
vgId
,
sTrace
(
"vgId:%d, sync timer, type:replicate count:%"
PRIu64
", lc-user:%"
PRIu64
,
ths
->
vgId
,
ths
->
heartbeatTimerCounter
,
ths
->
heartbeatTimerLogicClockUser
);
ths
->
heartbeatTimerCounter
,
ths
->
heartbeatTimerLogicClockUser
);
// syncNodeReplicate(ths, true);
}
}
}
else
{
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录