Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4f37eb50
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看板
未验证
提交
4f37eb50
编写于
11月 02, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 02, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17825 from taosdata/fix/TD-20052
refact: adjust sync.h and syncState
上级
c4d59126
1c77d538
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
112 addition
and
169 deletion
+112
-169
include/libs/sync/sync.h
include/libs/sync/sync.h
+17
-29
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+9
-8
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+8
-4
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+4
-2
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+18
-9
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+1
-0
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+2
-2
source/libs/sync/inc/syncTools.h
source/libs/sync/inc/syncTools.h
+1
-3
source/libs/sync/inc/syncUtil.h
source/libs/sync/inc/syncUtil.h
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+20
-65
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+1
-1
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+0
-12
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+7
-8
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+6
-8
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+3
-3
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+3
-3
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+8
-8
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+3
-3
未找到文件。
include/libs/sync/sync.h
浏览文件 @
4f37eb50
...
...
@@ -25,8 +25,6 @@ extern "C" {
#include "tlrucache.h"
#include "tmsgcb.h"
extern
bool
gRaftDetailLog
;
#define SYNC_RESP_TTL_MS 10000000
#define SYNC_SPEED_UP_HB_TIMER 400
#define SYNC_SPEED_UP_AFTER_MS (1000 * 20)
...
...
@@ -132,7 +130,7 @@ typedef struct SSnapshotMeta {
typedef
struct
SSyncFSM
{
void
*
data
;
void
(
*
FpCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpPreCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpRollBackCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
...
...
@@ -202,37 +200,27 @@ typedef struct SSyncInfo {
int32_t
(
*
syncEqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
}
SSyncInfo
;
int32_t
syncInit
();
void
syncCleanUp
();
bool
syncIsInit
();
int64_t
syncOpen
(
SSyncInfo
*
pSyncInfo
);
void
syncStart
(
int64_t
rid
);
void
syncStop
(
int64_t
rid
);
ESyncState
syncGetMyRole
(
int64_t
rid
);
bool
syncIsReady
(
int64_t
rid
);
const
char
*
syncGetMyRoleStr
(
int64_t
rid
);
bool
syncRestoreFinish
(
int64_t
rid
);
SyncTerm
syncGetMyTerm
(
int64_t
rid
);
SyncIndex
syncGetLastIndex
(
int64_t
rid
);
SyncIndex
syncGetCommitIndex
(
int64_t
rid
);
SyncGroupId
syncGetVgId
(
int64_t
rid
);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
// int32_t syncProposeBatch(int64_t rid, SRpcMsg** pMsgPArr, bool* pIsWeakArr, int32_t arrSize);
const
char
*
syncStr
(
ESyncState
state
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
int32_t
syncGetSnapshotByIndex
(
int64_t
rid
,
SyncIndex
index
,
SSnapshot
*
pSnapshot
);
typedef
struct
SSyncState
{
ESyncState
state
;
bool
restored
;
}
SSyncState
;
int32_t
syncInit
();
void
syncCleanUp
();
int64_t
syncOpen
(
SSyncInfo
*
pSyncInfo
);
void
syncStart
(
int64_t
rid
);
void
syncStop
(
int64_t
rid
);
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncProcessMsg
(
int64_t
rid
,
SRpcMsg
*
pMsg
);
int32_t
syncReconfig
(
int64_t
rid
,
SSyncCfg
*
pCfg
);
int32_t
syncLeaderTransfer
(
int64_t
rid
);
int32_t
syncBeginSnapshot
(
int64_t
rid
,
int64_t
lastApplyIndex
);
int32_t
syncEndSnapshot
(
int64_t
rid
);
int32_t
syncLeaderTransfer
(
int64_t
rid
);
int32_t
syncStepDown
(
int64_t
rid
,
SyncTerm
newTerm
);
int32_t
syncProcessMsg
(
int64_t
rid
,
SRpcMsg
*
pMsg
);
const
char
*
sync
UtilState2String
(
ESyncState
state
);
SSyncState
syncGetState
(
int64_t
rid
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
const
char
*
sync
Str
(
ESyncState
state
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
4f37eb50
...
...
@@ -487,14 +487,14 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
}
if
(
mndAcquireRpc
(
pMsg
->
info
.
node
)
==
0
)
return
0
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
const
char
*
role
=
syncGetMyRoleStr
(
pMnode
->
syncMgmt
.
sync
);
bool
restored
=
syncIsRestoreFinish
(
pMnode
->
syncMgmt
.
sync
);
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncState
state
=
syncGetState
(
pMnode
->
syncMgmt
.
sync
);
if
(
pMsg
->
msgType
==
TDMT_MND_TMQ_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TELEM_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TRANS_TIMER
||
pMsg
->
msgType
==
TDMT_MND_TTL_TIMER
||
pMsg
->
msgType
==
TDMT_MND_UPTIME_TIMER
)
{
mTrace
(
"timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s "
,
pMnode
->
restored
,
pMnode
->
stopped
,
restored
,
role
);
pMnode
->
stopped
,
state
.
restored
,
syncStr
(
state
.
restored
)
);
return
-
1
;
}
...
...
@@ -505,8 +505,8 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
mDebug
(
"msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d "
"role:%s, redirect numOfEps:%d inUse:%d"
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
terrstr
(),
pMnode
->
restored
,
pMnode
->
stopped
,
restored
,
role
,
epSet
.
numOfEps
,
epSet
.
inUse
);
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
),
terrstr
(),
pMnode
->
restored
,
pMnode
->
stopped
,
state
.
restored
,
syncStr
(
state
.
restored
),
epSet
.
numOfEps
,
epSet
.
inUse
);
if
(
epSet
.
numOfEps
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
...
...
@@ -729,8 +729,9 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
}
int32_t
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
)
{
pLoad
->
syncState
=
syncGetMyRole
(
pMnode
->
syncMgmt
.
sync
);
pLoad
->
syncRestore
=
pMnode
->
restored
;
SSyncState
state
=
syncGetState
(
pMnode
->
syncMgmt
.
sync
);
pLoad
->
syncState
=
state
.
state
;
pLoad
->
syncRestore
=
state
.
restored
;
mTrace
(
"mnode current syncState is %s, syncRestore:%d"
,
syncStr
(
pLoad
->
syncState
),
pLoad
->
syncRestore
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
4f37eb50
...
...
@@ -349,11 +349,15 @@ void mndSyncStop(SMnode *pMnode) {
}
bool
mndIsLeader
(
SMnode
*
pMnode
)
{
SSync
Mgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSync
State
state
=
syncGetState
(
pMnode
->
syncMgmt
.
sync
)
;
if
(
!
syncIsReady
(
pMgmt
->
sync
))
{
// get terrno from syncIsReady
// terrno = TSDB_CODE_SYN_NOT_LEADER;
if
(
state
.
state
!=
TAOS_SYNC_STATE_LEADER
||
!
state
.
restored
)
{
if
(
state
.
state
!=
TAOS_SYNC_STATE_LEADER
)
{
terrno
=
TSDB_CODE_SYN_NOT_LEADER
;
}
else
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
mDebug
(
"vgId:1, mnode not ready, state:%s, restore:%d"
,
syncStr
(
state
.
state
),
state
.
restored
);
return
false
;
}
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
4f37eb50
...
...
@@ -414,9 +414,11 @@ _exit:
}
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
SSyncState
state
=
syncGetState
(
pVnode
->
sync
);
pLoad
->
vgId
=
TD_VID
(
pVnode
);
pLoad
->
syncState
=
s
yncGetMyRole
(
pVnode
->
sync
)
;
pLoad
->
syncRestore
=
pVnode
->
restored
;
pLoad
->
syncState
=
s
tate
.
state
;
pLoad
->
syncRestore
=
state
.
restored
;
pLoad
->
cacheUsage
=
tsdbCacheGetUsage
(
pVnode
);
pLoad
->
numOfTables
=
metaGetTbNum
(
pVnode
->
pMeta
);
pLoad
->
numOfTimeSeries
=
metaGetTimeSeriesNum
(
pVnode
->
pMeta
);
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
4f37eb50
...
...
@@ -309,13 +309,13 @@ static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const S
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
vGTrace
(
"vgId:%d, commit-cb is excuted, fsm:%p, index:%"
PRId64
", term:%"
PRIu64
", msg-index:%"
PRId64
", weak:%d, code:%d, state:%d %s, type:%s"
,
syncGetVgId
(
pVnode
->
sync
)
,
pFsm
,
pMeta
->
index
,
pMeta
->
term
,
rpcMsg
.
info
.
conn
.
applyIndex
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
sync
UtilState2String
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
));
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
term
,
rpcMsg
.
info
.
conn
.
applyIndex
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
sync
Str
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
));
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
&
rpcMsg
);
}
else
{
SRpcMsg
rsp
=
{.
code
=
pMeta
->
code
,
.
info
=
pMsg
->
info
};
vError
(
"vgId:%d, commit-cb execute error, type:%s, index:%"
PRId64
", error:0x%x %s"
,
syncGetVgId
(
pVnode
->
sync
)
,
vError
(
"vgId:%d, commit-cb execute error, type:%s, index:%"
PRId64
", error:0x%x %s"
,
pVnode
->
config
.
vgId
,
TMSG_INFO
(
pMsg
->
msgType
),
pMeta
->
index
,
pMeta
->
code
,
tstrerror
(
pMeta
->
code
));
if
(
rsp
.
info
.
handle
!=
NULL
)
{
tmsgSendRsp
(
&
rsp
);
...
...
@@ -338,8 +338,8 @@ static void vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, con
static
void
vnodeSyncRollBackMsg
(
const
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
vTrace
(
"vgId:%d, rollback-cb is excuted, fsm:%p, index:%"
PRId64
", weak:%d, code:%d, state:%d %s, type:%s"
,
syncGetVgId
(
pVnode
->
sync
),
pFsm
,
pMeta
->
index
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
syncUtilState2String
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
));
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
syncStr
(
pMeta
->
state
)
,
TMSG_INFO
(
pMsg
->
msgType
));
}
#define USE_TSDB_SNAPSHOT
...
...
@@ -552,12 +552,21 @@ void vnodeSyncClose(SVnode *pVnode) {
syncStop
(
pVnode
->
sync
);
}
bool
vnodeIsRoleLeader
(
SVnode
*
pVnode
)
{
return
syncGetMyRole
(
pVnode
->
sync
)
==
TAOS_SYNC_STATE_LEADER
;
}
bool
vnodeIsRoleLeader
(
SVnode
*
pVnode
)
{
SSyncState
state
=
syncGetState
(
pVnode
->
sync
);
return
state
.
state
==
TAOS_SYNC_STATE_LEADER
;
}
bool
vnodeIsLeader
(
SVnode
*
pVnode
)
{
if
(
!
syncIsReady
(
pVnode
->
sync
))
{
vDebug
(
"vgId:%d, vnode not ready, state:%s, restore:%d"
,
pVnode
->
config
.
vgId
,
syncGetMyRoleStr
(
pVnode
->
sync
),
syncRestoreFinish
(
pVnode
->
sync
));
SSyncState
state
=
syncGetState
(
pVnode
->
sync
);
if
(
state
.
state
!=
TAOS_SYNC_STATE_LEADER
||
!
state
.
restored
)
{
if
(
state
.
state
!=
TAOS_SYNC_STATE_LEADER
)
{
terrno
=
TSDB_CODE_SYN_NOT_LEADER
;
}
else
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
vDebug
(
"vgId:%d, vnode not ready, state:%s, restore:%d"
,
pVnode
->
config
.
vgId
,
syncStr
(
state
.
state
),
state
.
restored
);
return
false
;
}
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
4f37eb50
...
...
@@ -52,6 +52,7 @@ typedef struct SSyncEnv {
}
SSyncEnv
;
SSyncEnv
*
syncEnv
();
bool
syncIsInit
();
int64_t
syncNodeAdd
(
SSyncNode
*
pNode
);
void
syncNodeRemove
(
int64_t
rid
);
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
4f37eb50
...
...
@@ -22,9 +22,9 @@ extern "C" {
#include "sync.h"
#include "syncTools.h"
#include "tlog.h"
#include "ttimer.h"
#include "taosdef.h"
#include "tlog.h"
#include "trpc.h"
#include "ttimer.h"
// clang-format off
...
...
include/libs/sy
nc/syncTools.h
→
source/libs/sync/i
nc/syncTools.h
浏览文件 @
4f37eb50
...
...
@@ -20,15 +20,13 @@
extern
"C"
{
#endif
#include "trpc.h"
// ------------------ ds -------------------
typedef
struct
SRaftId
{
SyncNodeId
addr
;
SyncGroupId
vgId
;
}
SRaftId
;
char
*
sync2SimpleStr
(
int64_t
rid
);
char
*
sync2SimpleStr
(
int64_t
rid
);
// for compatibility, the same as syncPropose
int32_t
syncForwardToPeer
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
...
...
source/libs/sync/inc/syncUtil.h
浏览文件 @
4f37eb50
...
...
@@ -49,7 +49,7 @@ int32_t syncUtilQuorum(int32_t replicaNum);
cJSON
*
syncUtilNodeInfo2Json
(
const
SNodeInfo
*
p
);
cJSON
*
syncUtilRaftId2Json
(
const
SRaftId
*
p
);
char
*
syncUtilRaftId2Str
(
const
SRaftId
*
p
);
const
char
*
sync
UtilState2String
(
ESyncState
state
);
const
char
*
sync
Str
(
ESyncState
state
);
bool
syncUtilCanPrint
(
char
c
);
char
*
syncUtilprintBin
(
char
*
ptr
,
uint32_t
len
);
char
*
syncUtilprintBin2
(
char
*
ptr
,
uint32_t
len
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
4f37eb50
...
...
@@ -505,50 +505,20 @@ int32_t syncForwardToPeer(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
return
ret
;
}
ESyncState
syncGetMyRole
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
TAOS_SYNC_STATE_ERROR
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
ESyncState
state
=
pSyncNode
->
state
;
syncNodeRelease
(
pSyncNode
);
return
state
;
}
SSyncState
syncGetState
(
int64_t
rid
)
{
SSyncState
state
=
{.
state
=
TAOS_SYNC_STATE_ERROR
};
bool
syncIsReady
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
false
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
bool
b
=
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_LEADER
)
&&
pSyncNode
->
restoreFinish
;
syncNodeRelease
(
pSyncNode
);
// if false, set error code
if
(
false
==
b
)
{
if
(
pSyncNode
->
state
!=
TAOS_SYNC_STATE_LEADER
)
{
terrno
=
TSDB_CODE_SYN_NOT_LEADER
;
}
else
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
}
}
return
b
;
}
bool
syncIsRestoreFinish
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
false
;
if
(
pSyncNode
!=
NULL
)
{
state
.
state
=
pSyncNode
->
state
;
state
.
restored
=
pSyncNode
->
restoreFinish
;
syncNodeRelease
(
pSyncNode
);
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
bool
b
=
pSyncNode
->
restoreFinish
;
syncNodeRelease
(
pSyncNode
);
return
b
;
return
state
;
}
#if 0
int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapshot) {
if (index < SYNC_INDEX_BEGIN) {
return -1;
...
...
@@ -618,6 +588,7 @@ int32_t syncGetSnapshotMetaByIndex(int64_t rid, SyncIndex snapshotIndex, struct
syncNodeRelease(pSyncNode);
return 0;
}
#endif
SyncIndex
syncNodeGetSnapshotConfigIndex
(
SSyncNode
*
pSyncNode
,
SyncIndex
snapshotLastApplyIndex
)
{
ASSERT
(
pSyncNode
->
pRaftCfg
->
configIndexCount
>=
1
);
...
...
@@ -635,23 +606,7 @@ SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapsho
return
lastIndex
;
}
const
char
*
syncGetMyRoleStr
(
int64_t
rid
)
{
const
char
*
s
=
syncUtilState2String
(
syncGetMyRole
(
rid
));
return
s
;
}
bool
syncRestoreFinish
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
false
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
bool
restoreFinish
=
pSyncNode
->
restoreFinish
;
syncNodeRelease
(
pSyncNode
);
return
restoreFinish
;
}
#if 0
SyncTerm syncGetMyTerm(int64_t rid) {
SSyncNode* pSyncNode = syncNodeAcquire(rid);
if (pSyncNode == NULL) {
...
...
@@ -719,6 +674,7 @@ void syncGetEpSet(int64_t rid, SEpSet* pEpSet) {
syncNodeRelease(pSyncNode);
}
#endif
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
...
...
@@ -742,7 +698,6 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) {
syncNodeRelease
(
pSyncNode
);
}
static
void
syncGetAndDelRespRpc
(
SSyncNode
*
pSyncNode
,
uint64_t
index
,
SRpcHandleInfo
*
pInfo
)
{
SRespStub
stub
;
int32_t
ret
=
syncRespMgrGetAndDel
(
pSyncNode
->
pSyncRespMgr
,
index
,
&
stub
);
...
...
@@ -877,7 +832,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
}
else
{
ret
=
-
1
;
terrno
=
TSDB_CODE_SYN_NOT_LEADER
;
sError
(
"vgId:%d, sync propose not leader, %s, type:%s"
,
pSyncNode
->
vgId
,
sync
UtilState2String
(
pSyncNode
->
state
),
sError
(
"vgId:%d, sync propose not leader, %s, type:%s"
,
pSyncNode
->
vgId
,
sync
Str
(
pSyncNode
->
state
),
TMSG_INFO
(
pMsg
->
msgType
));
goto
_END
;
}
...
...
@@ -1603,7 +1558,7 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
// tla+ server vars
cJSON_AddNumberToObject
(
pRoot
,
"state"
,
pSyncNode
->
state
);
cJSON_AddStringToObject
(
pRoot
,
"state_str"
,
sync
UtilState2String
(
pSyncNode
->
state
));
cJSON_AddStringToObject
(
pRoot
,
"state_str"
,
sync
Str
(
pSyncNode
->
state
));
cJSON_AddItemToObject
(
pRoot
,
"pRaftStore"
,
raftStore2Json
(
pSyncNode
->
pRaftStore
));
// tla+ candidate vars
...
...
@@ -1743,7 +1698,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
"stgy:%d, bch:%d, "
"r-num:%d, "
"lcfg:%"
PRId64
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s, %s"
,
pSyncNode
->
vgId
,
sync
UtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
sync
Str
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
pSyncNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
...
...
@@ -1767,7 +1722,7 @@ inline void syncNodeEventLog(const SSyncNode* pSyncNode, char* str) {
"stgy:%d, bch:%d, "
"r-num:%d, "
"lcfg:%"
PRId64
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s, %s"
,
pSyncNode
->
vgId
,
sync
UtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
sync
Str
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
pSyncNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
...
...
@@ -1821,7 +1776,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
"stgy:%d, bch:%d, "
"r-num:%d, "
"lcfg:%"
PRId64
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s"
,
pSyncNode
->
vgId
,
sync
UtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
sync
Str
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
pSyncNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
...
...
@@ -1843,7 +1798,7 @@ inline void syncNodeErrorLog(const SSyncNode* pSyncNode, char* str) {
"stgy:%d, bch:%d, "
"r-num:%d, "
"lcfg:%"
PRId64
", chging:%d, rsto:%d, dquorum:%d, elt:%"
PRId64
", hb:%"
PRId64
", %s"
,
pSyncNode
->
vgId
,
sync
UtilState2String
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
vgId
,
sync
Str
(
pSyncNode
->
state
),
str
,
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
pSyncNode
->
minMatchIndex
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
pRaftCfg
->
snapshotStrategy
,
pSyncNode
->
pRaftCfg
->
batchSize
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
...
...
@@ -1875,9 +1830,9 @@ inline char* syncNode2SimpleStr(const SSyncNode* pSyncNode) {
", sby:%d, "
"r-num:%d, "
"lcfg:%"
PRId64
", chging:%d, rsto:%d"
,
pSyncNode
->
vgId
,
sync
UtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
);
pSyncNode
->
vgId
,
sync
Str
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
commitIndex
,
logBeginIndex
,
logLastIndex
,
snapshot
.
lastApplyIndex
,
pSyncNode
->
pRaftCfg
->
isStandBy
,
pSyncNode
->
replicaNum
,
pSyncNode
->
pRaftCfg
->
lastConfigIndex
,
pSyncNode
->
changing
,
pSyncNode
->
restoreFinish
);
return
s
;
}
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
4f37eb50
...
...
@@ -2413,7 +2413,7 @@ cJSON* syncApplyMsg2Json(const SyncApplyMsg* pMsg) {
cJSON_AddNumberToObject
(
pRoot
,
"fsmMeta.isWeak"
,
pMsg
->
fsmMeta
.
isWeak
);
cJSON_AddNumberToObject
(
pRoot
,
"fsmMeta.code"
,
pMsg
->
fsmMeta
.
code
);
cJSON_AddNumberToObject
(
pRoot
,
"fsmMeta.state"
,
pMsg
->
fsmMeta
.
state
);
cJSON_AddStringToObject
(
pRoot
,
"fsmMeta.state.str"
,
sync
UtilState2String
(
pMsg
->
fsmMeta
.
state
));
cJSON_AddStringToObject
(
pRoot
,
"fsmMeta.state.str"
,
sync
Str
(
pMsg
->
fsmMeta
.
state
));
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pMsg
->
fsmMeta
.
seqNum
);
cJSON_AddStringToObject
(
pRoot
,
"fsmMeta.seqNum"
,
u64buf
);
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
4f37eb50
...
...
@@ -176,18 +176,6 @@ char* syncUtilRaftId2Str(const SRaftId* p) {
return
serialized
;
}
const
char
*
syncUtilState2String
(
ESyncState
state
)
{
if
(
state
==
TAOS_SYNC_STATE_FOLLOWER
)
{
return
"follower"
;
}
else
if
(
state
==
TAOS_SYNC_STATE_CANDIDATE
)
{
return
"candidate"
;
}
else
if
(
state
==
TAOS_SYNC_STATE_LEADER
)
{
return
"leader"
;
}
else
{
return
"state_error"
;
}
}
bool
syncUtilCanPrint
(
char
c
)
{
if
(
c
>=
32
&&
c
<=
126
)
{
return
true
;
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
4f37eb50
...
...
@@ -47,8 +47,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
)
,
cbMeta
.
flag
,
cbMeta
.
term
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
...
@@ -57,10 +57,10 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncStr
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -68,8 +68,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncStr
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
4f37eb50
...
...
@@ -45,8 +45,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncStr
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
...
@@ -55,10 +54,10 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
char
logBuf
[
256
]
=
{
0
};
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncStr
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -66,8 +65,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s flag:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncUtilState2String
(
cbMeta
.
state
),
cbMeta
.
flag
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
syncStr
(
cbMeta
.
state
),
cbMeta
.
flag
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
4f37eb50
...
...
@@ -42,7 +42,7 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
...
@@ -53,7 +53,7 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -61,7 +61,7 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
4f37eb50
...
...
@@ -45,7 +45,7 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
else
{
sTrace
(
"==callback== ==CommitCb== do not apply again %"
PRId64
,
cbMeta
.
index
);
...
...
@@ -56,7 +56,7 @@ void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta)
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -64,7 +64,7 @@ void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
4f37eb50
...
...
@@ -44,8 +44,8 @@ void CommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
)
,
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -56,8 +56,8 @@ void PreCommitCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta)
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
)
,
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -68,8 +68,8 @@ void RollBackCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta) {
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
)
,
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -168,8 +168,8 @@ void LeaderTransferCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbM
", isWeak:%d, code:%d, state:%d %s, flag:%"
PRIu64
", term:%"
PRIu64
" "
"currentTerm:%"
PRIu64
"
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
)
,
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
),
cbMeta
.
flag
,
cbMeta
.
term
,
cbMeta
.
currentTerm
);
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
4f37eb50
...
...
@@ -35,7 +35,7 @@ void CommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -43,7 +43,7 @@ void PreCommitCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta)
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
@@ -51,7 +51,7 @@ void RollBackCb(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%"
PRId64
", isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
UtilState2String
(
cbMeta
.
state
));
cbMeta
.
index
,
cbMeta
.
isWeak
,
cbMeta
.
code
,
cbMeta
.
state
,
sync
Str
(
cbMeta
.
state
));
syncRpcMsgLog2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录