Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a7807d3e
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
a7807d3e
编写于
12月 03, 2022
作者:
B
Benguang Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: synchronize syncPropose for executing blocking msgs in vnodeProposeMsg
上级
7eca2127
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
54 addition
and
15 deletion
+54
-15
include/common/tmsg.h
include/common/tmsg.h
+4
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+2
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+34
-11
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+5
-1
source/libs/sync/src/syncPipeline.c
source/libs/sync/src/syncPipeline.c
+7
-2
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
a7807d3e
...
...
@@ -66,6 +66,10 @@ extern int32_t tMsgDict[];
typedef
uint16_t
tmsg_t
;
static
inline
bool
vnodeIsMsgBlock
(
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
);
}
/* ------------------------ OTHER DEFINITIONS ------------------------ */
// IE type
#define TSDB_IE_TYPE_SEC 1
...
...
include/util/taoserror.h
浏览文件 @
a7807d3e
...
...
@@ -381,6 +381,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527)
#define TSDB_CODE_VND_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528)
#define TSDB_CODE_VND_STOPPED TAOS_DEF_ERROR_CODE(0, 0x0529)
#define TSDB_CODE_VND_DUP_REQUEST TAOS_DEF_ERROR_CODE(0, 0x0530)
// tsdb
#define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600)
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
a7807d3e
...
...
@@ -181,14 +181,15 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
if
(
version
<=
pVnode
->
state
.
applied
)
{
vError
(
"vgId:%d, duplicate write request. version: %"
PRId64
", applied: %"
PRId64
""
,
TD_VID
(
pVnode
),
version
,
pVnode
->
state
.
applied
);
terrno
=
TSDB_CODE_VND_DUP_REQUEST
;
pRsp
->
info
.
handle
=
NULL
;
return
-
1
;
}
vDebug
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
version
);
ASSERT
(
pVnode
->
state
.
applyTerm
<=
pMsg
->
info
.
conn
.
applyTerm
);
ASSERT
(
pVnode
->
state
.
applyTerm
<=
pMsg
->
info
.
conn
.
applyTerm
);
pVnode
->
state
.
applied
=
version
;
pVnode
->
state
.
applyTerm
=
pMsg
->
info
.
conn
.
applyTerm
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
a7807d3e
...
...
@@ -18,14 +18,15 @@
#define BATCH_ENABLE 0
static
inline
bool
vnodeIsMsgBlock
(
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
);
}
static
inline
bool
vnodeIsMsgWeak
(
tmsg_t
type
)
{
return
false
;
}
static
inline
void
vnodeWaitBlockMsg
(
SVnode
*
pVnode
,
const
SRpcMsg
*
pMsg
)
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
vGTrace
(
"vgId:%d, msg:%p wait block, type:%s"
,
pVnode
->
config
.
vgId
,
pMsg
,
TMSG_INFO
(
pMsg
->
msgType
));
tsem_wait
(
&
pVnode
->
syncSem
);
}
static
inline
void
vnodeWaitBlockMsgOld
(
SVnode
*
pVnode
,
const
SRpcMsg
*
pMsg
)
{
if
(
vnodeIsMsgBlock
(
pMsg
->
msgType
))
{
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
taosThreadMutexLock
(
&
pVnode
->
lock
);
...
...
@@ -115,21 +116,31 @@ static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code)
static
void
inline
vnodeProposeBatchMsg
(
SVnode
*
pVnode
,
SRpcMsg
**
pMsgArr
,
bool
*
pIsWeakArr
,
int32_t
*
arrSize
)
{
if
(
*
arrSize
<=
0
)
return
;
SRpcMsg
*
pLastMsg
=
pMsgArr
[
*
arrSize
-
1
];
taosThreadMutexLock
(
&
pVnode
->
lock
);
int32_t
code
=
syncProposeBatch
(
pVnode
->
sync
,
pMsgArr
,
pIsWeakArr
,
*
arrSize
);
bool
wait
=
(
code
==
0
&&
vnodeIsBlockMsg
(
pLastMsg
->
msgType
));
if
(
wait
)
{
ASSERT
(
!
pVnode
->
blocked
);
pVnode
->
blocked
=
true
;
}
taosThreadMutexUnlock
(
&
pVnode
->
lock
);
if
(
code
>
0
)
{
for
(
int32_t
i
=
0
;
i
<
*
arrSize
;
++
i
)
{
vnodeHandleWriteMsg
(
pVnode
,
pMsgArr
[
i
]);
}
}
else
if
(
code
==
0
)
{
vnodeWaitBlockMsg
(
pVnode
,
pMsgArr
[
*
arrSize
-
1
]);
}
else
{
}
else
if
(
code
<
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
for
(
int32_t
i
=
0
;
i
<
*
arrSize
;
++
i
)
{
vnodeHandleProposeError
(
pVnode
,
pMsgArr
[
i
],
code
);
}
}
if
(
wait
)
vnodeWaitBlockMsg
(
pVnode
,
pLastMsg
);
pLastMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
*
arrSize
;
++
i
)
{
SRpcMsg
*
pMsg
=
pMsgArr
[
i
];
const
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
...
...
@@ -206,16 +217,23 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs)
#else
static
int32_t
inline
vnodeProposeMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
taosThreadMutexLock
(
&
pVnode
->
lock
);
int32_t
code
=
syncPropose
(
pVnode
->
sync
,
pMsg
,
isWeak
);
bool
wait
=
(
code
==
0
&&
vnodeIsMsgBlock
(
pMsg
->
msgType
));
if
(
wait
)
{
ASSERT
(
!
pVnode
->
blocked
);
pVnode
->
blocked
=
true
;
}
taosThreadMutexUnlock
(
&
pVnode
->
lock
);
if
(
code
>
0
)
{
vnodeHandleWriteMsg
(
pVnode
,
pMsg
);
}
else
if
(
code
==
0
)
{
vnodeWaitBlockMsg
(
pVnode
,
pMsg
);
}
else
{
}
else
if
(
code
<
0
)
{
if
(
terrno
!=
0
)
code
=
terrno
;
vnodeHandleProposeError
(
pVnode
,
pMsg
,
code
);
}
if
(
wait
)
vnodeWaitBlockMsg
(
pVnode
,
pMsg
);
return
code
;
}
...
...
@@ -274,6 +292,11 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
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
));
}
SRpcMsg
rsp
=
{.
code
=
pMsg
->
code
,
.
info
=
pMsg
->
info
};
if
(
rsp
.
code
==
0
)
{
if
(
vnodeProcessWriteMsg
(
pVnode
,
pMsg
,
pMsg
->
info
.
conn
.
applyIndex
,
&
rsp
)
<
0
)
{
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
a7807d3e
...
...
@@ -2638,7 +2638,11 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn
(
*
pRetIndex
)
=
index
;
}
return
syncNodeAppend
(
ths
,
pEntry
);
int32_t
code
=
syncNodeAppend
(
ths
,
pEntry
);
if
(
code
<
0
&&
ths
->
vgId
!=
1
&&
vnodeIsMsgBlock
(
pEntry
->
originalRpcType
))
{
ASSERT
(
false
&&
"failed to append blocking msg"
);
}
return
code
;
}
return
-
1
;
...
...
source/libs/sync/src/syncPipeline.c
浏览文件 @
a7807d3e
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "syncPipeline.h"
#include "syncCommit.h"
#include "syncIndexMgr.h"
#include "syncInt.h"
#include "syncRaftEntry.h"
...
...
@@ -442,6 +443,11 @@ int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, Syn
return
0
;
}
if
(
pNode
->
vgId
!=
1
&&
vnodeIsMsgBlock
(
pEntry
->
originalRpcType
))
{
sTrace
(
"vgId:%d, blocking msg ready to execute. index:%"
PRId64
", term: %"
PRId64
", type: %s"
,
pNode
->
vgId
,
pEntry
->
index
,
pEntry
->
term
,
TMSG_INFO
(
pEntry
->
originalRpcType
));
}
SRpcMsg
rpcMsg
=
{
0
};
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
...
...
@@ -514,9 +520,8 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm
}
continue
;
}
if
(
syncLogFsmExecute
(
pNode
,
pFsm
,
role
,
term
,
pEntry
)
!=
0
)
{
sError
(
"vgId:%d, failed to
commit
sync log entry. index:%"
PRId64
", term:%"
PRId64
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
);
goto
_out
;
...
...
source/util/src/terror.c
浏览文件 @
a7807d3e
...
...
@@ -326,6 +326,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_NOT_EXISTS, "Table column not exis
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_COL_SUBSCRIBED
,
"Table column is subscribed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_NO_AVAIL_BUFPOOL
,
"No availabe buffer pool"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_STOPPED
,
"Vnode stopped"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_VND_DUP_REQUEST
,
"Duplicate write request"
)
// tsdb
TAOS_DEFINE_ERROR
(
TSDB_CODE_TDB_INVALID_TABLE_ID
,
"Invalid table ID"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录