Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
56cf8863
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
56cf8863
编写于
12月 27, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19160 from taosdata/enh/TD-21536
fix: handle error if sync buffer is full
上级
80a04d4a
794fb5d1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
26 addition
and
15 deletion
+26
-15
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+2
-2
source/libs/sync/inc/syncPipeline.h
source/libs/sync/inc/syncPipeline.h
+2
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+7
-3
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+13
-10
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/util/taoserror.h
浏览文件 @
56cf8863
...
...
@@ -520,6 +520,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913)
#define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914)
#define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal
#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) //
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
// tq
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
56cf8863
...
...
@@ -391,9 +391,9 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm
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"
,
", weak:%d, code:%d, state:%d %s, type:%s
code:0x%x
"
,
pVnode
->
config
.
vgId
,
pFsm
,
pMeta
->
index
,
pMeta
->
term
,
pMsg
->
info
.
conn
.
applyIndex
,
pMeta
->
isWeak
,
pMeta
->
code
,
pMeta
->
state
,
syncStr
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
));
pMeta
->
state
,
syncStr
(
pMeta
->
state
),
TMSG_INFO
(
pMsg
->
msgType
)
,
pMsg
->
code
);
return
tmsgPutToQueue
(
&
pVnode
->
msgCb
,
APPLY_QUEUE
,
pMsg
);
}
...
...
source/libs/sync/inc/syncPipeline.h
浏览文件 @
56cf8863
...
...
@@ -109,6 +109,8 @@ SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode,
int32_t
syncLogBufferValidate
(
SSyncLogBuffer
*
pBuf
);
int32_t
syncLogBufferRollback
(
SSyncLogBuffer
*
pBuf
,
SSyncNode
*
pNode
,
SyncIndex
toIndex
);
int32_t
syncLogFsmExecute
(
SSyncNode
*
pNode
,
SSyncFSM
*
pFsm
,
ESyncState
role
,
SyncTerm
term
,
SSyncRaftEntry
*
pEntry
,
int32_t
applyCode
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
56cf8863
...
...
@@ -2386,7 +2386,11 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand
int32_t
syncNodeAppend
(
SSyncNode
*
ths
,
SSyncRaftEntry
*
pEntry
)
{
// append to log buffer
if
(
syncLogBufferAppend
(
ths
->
pLogBuf
,
ths
,
pEntry
)
<
0
)
{
sError
(
"vgId:%d, failed to enqueue sync log buffer. index:%"
PRId64
""
,
ths
->
vgId
,
pEntry
->
index
);
sError
(
"vgId:%d, failed to enqueue sync log buffer, index:%"
PRId64
,
ths
->
vgId
,
pEntry
->
index
);
terrno
=
TSDB_CODE_SYN_BUFFER_FULL
;
(
void
)
syncLogFsmExecute
(
ths
,
ths
->
pFsm
,
ths
->
state
,
ths
->
pRaftStore
->
currentTerm
,
pEntry
,
TSDB_CODE_SYN_BUFFER_FULL
);
syncEntryDestroy
(
pEntry
);
return
-
1
;
}
...
...
@@ -2685,8 +2689,8 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn
}
int32_t
code
=
syncNodeAppend
(
ths
,
pEntry
);
if
(
code
<
0
&&
ths
->
vgId
!=
1
&&
vnodeIsMsgBlock
(
pEntry
->
originalRpcType
)
)
{
ASSERTS
(
false
,
"failed to append blocking msg"
);
if
(
code
<
0
)
{
sNError
(
ths
,
"failed to append blocking msg"
);
}
return
code
;
}
...
...
source/libs/sync/src/syncPipeline.c
浏览文件 @
56cf8863
...
...
@@ -26,6 +26,11 @@
#include "syncSnapshot.h"
#include "syncUtil.h"
static
bool
syncIsMsgBlock
(
tmsg_t
type
)
{
return
(
type
==
TDMT_VND_CREATE_TABLE
)
||
(
type
==
TDMT_VND_ALTER_TABLE
)
||
(
type
==
TDMT_VND_DROP_TABLE
)
||
(
type
==
TDMT_VND_UPDATE_TAG_VAL
)
||
(
type
==
TDMT_VND_ALTER_CONFIRM
);
}
int64_t
syncLogBufferGetEndIndex
(
SSyncLogBuffer
*
pBuf
)
{
taosThreadMutexLock
(
&
pBuf
->
mutex
);
int64_t
index
=
pBuf
->
endIndex
;
...
...
@@ -441,26 +446,25 @@ _out:
return
matchIndex
;
}
int32_t
syncLogFsmExecute
(
SSyncNode
*
pNode
,
SSyncFSM
*
pFsm
,
ESyncState
role
,
SyncTerm
term
,
SSyncRaftEntry
*
pEntry
)
{
ASSERTS
(
pFsm
->
FpCommitCb
!=
NULL
,
"No commit cb registered for the FSM"
);
int32_t
syncLogFsmExecute
(
SSyncNode
*
pNode
,
SSyncFSM
*
pFsm
,
ESyncState
role
,
SyncTerm
term
,
SSyncRaftEntry
*
pEntry
,
int32_t
applyCode
)
{
if
((
pNode
->
replicaNum
==
1
)
&&
pNode
->
restoreFinish
&&
pNode
->
vgId
!=
1
)
{
return
0
;
}
if
(
pNode
->
vgId
!=
1
&&
vnode
IsMsgBlock
(
pEntry
->
originalRpcType
))
{
sTrace
(
"vgId:%d, blocking msg ready to execute
. index:%"
PRId64
", term: %"
PRId64
", type: %s"
,
pNode
->
vgId
,
p
Entry
->
index
,
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
)
);
if
(
pNode
->
vgId
!=
1
&&
sync
IsMsgBlock
(
pEntry
->
originalRpcType
))
{
sTrace
(
"vgId:%d, blocking msg ready to execute
, index:%"
PRId64
", term:%"
PRId64
", type:%s code:0x%x"
,
p
Node
->
vgId
,
pEntry
->
index
,
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
),
applyCode
);
}
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
.
code
=
applyCode
};
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
SFsmCbMeta
cbMeta
=
{
0
};
cbMeta
.
index
=
pEntry
->
index
;
cbMeta
.
lastConfigIndex
=
syncNodeGetSnapshotConfigIndex
(
pNode
,
pEntry
->
index
);
cbMeta
.
isWeak
=
pEntry
->
isWeak
;
cbMeta
.
code
=
0
;
cbMeta
.
code
=
applyCode
;
cbMeta
.
state
=
role
;
cbMeta
.
seqNum
=
pEntry
->
seqNum
;
cbMeta
.
term
=
pEntry
->
term
;
...
...
@@ -469,7 +473,6 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn
(
void
)
syncRespMgrGetAndDel
(
pNode
->
pSyncRespMgr
,
cbMeta
.
seqNum
,
&
rpcMsg
.
info
);
int32_t
code
=
pFsm
->
FpCommitCb
(
pFsm
,
&
rpcMsg
,
&
cbMeta
);
ASSERT
(
rpcMsg
.
pCont
==
NULL
);
return
code
;
}
...
...
@@ -520,7 +523,7 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
));
}
if
(
syncLogFsmExecute
(
pNode
,
pFsm
,
role
,
term
,
pEntry
)
!=
0
)
{
if
(
syncLogFsmExecute
(
pNode
,
pFsm
,
role
,
term
,
pEntry
,
0
)
!=
0
)
{
sError
(
"vgId:%d, failed to execute sync log entry. index:%"
PRId64
", term:%"
PRId64
", role: %d, current term: %"
PRId64
,
vgId
,
pEntry
->
index
,
pEntry
->
term
,
role
,
term
);
...
...
source/util/src/terror.c
浏览文件 @
56cf8863
...
...
@@ -407,6 +407,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_STANDBY_NOT_READY, "Sync not ready for st
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_BATCH_ERROR
,
"Sync batch error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_RESTORING
,
"Sync is restoring"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG
,
"Sync invalid snapshot msg"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_BUFFER_FULL
,
"Sync buffer is full"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_SYN_INTERNAL_ERROR
,
"Sync internal error"
)
//tq
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录