Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
28efd7dc
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
28efd7dc
编写于
5月 31, 2023
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: check trans conflicts in mndTransValidate
上级
4a6d8185
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
11 deletion
+21
-11
include/libs/sync/sync.h
include/libs/sync/sync.h
+5
-5
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+13
-3
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+3
-3
未找到文件。
include/libs/sync/sync.h
浏览文件 @
28efd7dc
...
@@ -154,14 +154,14 @@ typedef struct SSnapshotMeta {
...
@@ -154,14 +154,14 @@ typedef struct SSnapshotMeta {
typedef
struct
SSyncFSM
{
typedef
struct
SSyncFSM
{
void
*
data
;
void
*
data
;
int32_t
(
*
FpCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
int32_t
(
*
FpCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
);
SyncIndex
(
*
FpAppliedIndexCb
)(
const
struct
SSyncFSM
*
pFsm
);
SyncIndex
(
*
FpAppliedIndexCb
)(
const
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpPreCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
int32_t
(
*
FpPreCommitCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
);
void
(
*
FpRollBackCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpRollBackCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
);
void
(
*
FpRestoreFinishCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SyncIndex
commitIdx
);
void
(
*
FpRestoreFinishCb
)(
const
struct
SSyncFSM
*
pFsm
,
const
SyncIndex
commitIdx
);
void
(
*
FpReConfigCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SReConfigCbMeta
*
pMeta
);
void
(
*
FpReConfigCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SReConfigCbMeta
*
pMeta
);
void
(
*
FpLeaderTransferCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
);
void
(
*
FpLeaderTransferCb
)(
const
struct
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
);
bool
(
*
FpApplyQueueEmptyCb
)(
const
struct
SSyncFSM
*
pFsm
);
bool
(
*
FpApplyQueueEmptyCb
)(
const
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpApplyQueueItems
)(
const
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpApplyQueueItems
)(
const
struct
SSyncFSM
*
pFsm
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
28efd7dc
...
@@ -133,6 +133,11 @@ _OUT:
...
@@ -133,6 +133,11 @@ _OUT:
static
int32_t
mndTransValidateImp
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
static
int32_t
mndTransValidateImp
(
SMnode
*
pMnode
,
STrans
*
pTrans
)
{
if
(
pTrans
->
stage
==
TRN_STAGE_PREPARE
)
{
if
(
pTrans
->
stage
==
TRN_STAGE_PREPARE
)
{
if
(
mndTransCheckConflict
(
pMnode
,
pTrans
)
<
0
)
{
mError
(
"trans:%d, failed to validate trans conflicts."
,
pTrans
->
id
);
return
-
1
;
}
return
mndTransValidatePrepareStage
(
pMnode
,
pTrans
);
return
mndTransValidatePrepareStage
(
pMnode
,
pTrans
);
}
}
return
0
;
return
0
;
...
@@ -153,10 +158,12 @@ static int32_t mndTransValidate(SMnode *pMnode, SSdbRaw *pRaw) {
...
@@ -153,10 +158,12 @@ static int32_t mndTransValidate(SMnode *pMnode, SSdbRaw *pRaw) {
_OUT:
_OUT:
if
(
pTrans
)
mndTransDropData
(
pTrans
);
if
(
pTrans
)
mndTransDropData
(
pTrans
);
if
(
pRow
)
taosMemoryFreeClear
(
pRow
);
if
(
pRow
)
taosMemoryFreeClear
(
pRow
);
if
(
code
)
terrno
=
(
terrno
?
terrno
:
TSDB_CODE_MND_TRANS_CONFLICT
);
return
code
;
return
code
;
}
}
int32_t
mndProcessWriteMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
int32_t
mndProcessWriteMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
)
{
terrno
=
TSDB_CODE_SUCCESS
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSdbRaw
*
pRaw
=
pMsg
->
pCont
;
SSdbRaw
*
pRaw
=
pMsg
->
pCont
;
STrans
*
pTrans
=
NULL
;
STrans
*
pTrans
=
NULL
;
...
@@ -177,6 +184,8 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, const SFsmCbMeta *pMet
...
@@ -177,6 +184,8 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, const SFsmCbMeta *pMet
code
=
mndTransValidate
(
pMnode
,
pRaw
);
code
=
mndTransValidate
(
pMnode
,
pRaw
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"trans:%d, failed to validate requested trans since %s"
,
transId
,
terrstr
());
mError
(
"trans:%d, failed to validate requested trans since %s"
,
transId
,
terrstr
());
code
=
0
;
pMeta
->
code
=
terrno
;
goto
_OUT
;
goto
_OUT
;
}
}
...
@@ -236,7 +245,7 @@ _OUT:
...
@@ -236,7 +245,7 @@ _OUT:
return
0
;
return
0
;
}
}
int32_t
mndSyncCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
int32_t
mndSyncCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
int32_t
code
=
pMsg
->
code
;
int32_t
code
=
pMsg
->
code
;
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
...
@@ -245,6 +254,7 @@ int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *
...
@@ -245,6 +254,7 @@ int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *
pMsg
->
info
.
conn
.
applyIndex
=
pMeta
->
index
;
pMsg
->
info
.
conn
.
applyIndex
=
pMeta
->
index
;
pMsg
->
info
.
conn
.
applyTerm
=
pMeta
->
term
;
pMsg
->
info
.
conn
.
applyTerm
=
pMeta
->
term
;
pMeta
->
code
=
0
;
atomic_store_64
(
&
pMnode
->
applied
,
pMsg
->
info
.
conn
.
applyIndex
);
atomic_store_64
(
&
pMnode
->
applied
,
pMsg
->
info
.
conn
.
applyIndex
);
...
@@ -255,7 +265,7 @@ int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *
...
@@ -255,7 +265,7 @@ int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *
code
=
mndProcessWriteMsg
(
pMnode
,
pMsg
,
pMeta
);
code
=
mndProcessWriteMsg
(
pMnode
,
pMsg
,
pMeta
);
_OUT:
_OUT:
mndPostMgmtCode
(
pMnode
,
code
);
mndPostMgmtCode
(
pMnode
,
code
?
code
:
pMeta
->
code
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
pMsg
->
pCont
=
NULL
;
return
code
;
return
code
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
28efd7dc
...
@@ -431,7 +431,7 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
...
@@ -431,7 +431,7 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
return
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
pMsg
);
return
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
pMsg
);
}
}
static
int32_t
vnodeSyncCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
static
int32_t
vnodeSyncCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
)
{
if
(
pMsg
->
code
==
0
)
{
if
(
pMsg
->
code
==
0
)
{
return
vnodeSyncApplyMsg
(
pFsm
,
pMsg
,
pMeta
);
return
vnodeSyncApplyMsg
(
pFsm
,
pMsg
,
pMeta
);
}
}
...
@@ -451,7 +451,7 @@ static int32_t vnodeSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFs
...
@@ -451,7 +451,7 @@ static int32_t vnodeSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFs
return
0
;
return
0
;
}
}
static
int32_t
vnodeSyncPreCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
static
int32_t
vnodeSyncPreCommitMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
)
{
if
(
pMeta
->
isWeak
==
1
)
{
if
(
pMeta
->
isWeak
==
1
)
{
return
vnodeSyncApplyMsg
(
pFsm
,
pMsg
,
pMeta
);
return
vnodeSyncApplyMsg
(
pFsm
,
pMsg
,
pMeta
);
}
}
...
@@ -463,7 +463,7 @@ static SyncIndex vnodeSyncAppliedIndex(const SSyncFSM *pFSM) {
...
@@ -463,7 +463,7 @@ static SyncIndex vnodeSyncAppliedIndex(const SSyncFSM *pFSM) {
return
atomic_load_64
(
&
pVnode
->
state
.
applied
);
return
atomic_load_64
(
&
pVnode
->
state
.
applied
);
}
}
static
void
vnodeSyncRollBackMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
const
SFsmCbMeta
*
pMeta
)
{
static
void
vnodeSyncRollBackMsg
(
const
SSyncFSM
*
pFsm
,
SRpcMsg
*
pMsg
,
SFsmCbMeta
*
pMeta
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
SVnode
*
pVnode
=
pFsm
->
data
;
vTrace
(
"vgId:%d, rollback-cb is excuted, fsm:%p, index:%"
PRId64
", weak:%d, code:%d, state:%d %s, type:%s"
,
vTrace
(
"vgId:%d, rollback-cb is excuted, fsm:%p, index:%"
PRId64
", weak:%d, code:%d, state:%d %s, type:%s"
,
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
syncStr
(
pMeta
->
state
),
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
syncStr
(
pMeta
->
state
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录