Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
22bfcc34
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看板
未验证
提交
22bfcc34
编写于
5月 21, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
5月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12799 from taosdata/fix/valgrind
refactor: free rpcCont on error occured
上级
fb6bebe6
44d9cc8d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
56 addition
and
63 deletion
+56
-63
include/util/taoserror.h
include/util/taoserror.h
+2
-2
source/dnode/mgmt/node_mgmt/src/dmProc.c
source/dnode/mgmt/node_mgmt/src/dmProc.c
+15
-9
source/dnode/mgmt/node_mgmt/src/dmTransport.c
source/dnode/mgmt/node_mgmt/src/dmTransport.c
+27
-49
source/dnode/mgmt/node_util/inc/dmUtil.h
source/dnode/mgmt/node_util/inc/dmUtil.h
+1
-0
source/dnode/mgmt/node_util/src/dmEps.c
source/dnode/mgmt/node_util/src/dmEps.c
+11
-0
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+0
-3
未找到文件。
include/util/taoserror.h
浏览文件 @
22bfcc34
...
...
@@ -282,8 +282,8 @@ int32_t* taosGetErrno();
// dnode
#define TSDB_CODE_NODE_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0400)
#define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0401)
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040
3
)
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040
4
)
#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040
2
)
#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040
3
)
// vnode
#define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500)
...
...
source/dnode/mgmt/node_mgmt/src/dmProc.c
浏览文件 @
22bfcc34
...
...
@@ -142,13 +142,14 @@ static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg
queue
->
tail
=
headLen
+
bodyLen
;
}
else
if
(
remain
<
8
+
headLen
)
{
memcpy
(
queue
->
pBuffer
+
queue
->
tail
+
8
,
pHead
,
remain
-
8
);
memcpy
(
queue
->
pBuffer
,
(
char
*
)
pHead
+
remain
-
8
,
rawHeadLen
-
(
remain
-
8
));
memcpy
(
queue
->
pBuffer
,
(
char
*
)
pHead
+
remain
-
8
,
rawHeadLen
-
(
remain
-
8
));
if
(
rawBodyLen
>
0
)
memcpy
(
queue
->
pBuffer
+
headLen
-
(
remain
-
8
),
pBody
,
rawBodyLen
);
queue
->
tail
=
headLen
-
(
remain
-
8
)
+
bodyLen
;
}
else
if
(
remain
<
8
+
headLen
+
bodyLen
)
{
memcpy
(
queue
->
pBuffer
+
queue
->
tail
+
8
,
pHead
,
rawHeadLen
);
if
(
rawBodyLen
>
0
)
memcpy
(
queue
->
pBuffer
+
queue
->
tail
+
8
+
headLen
,
pBody
,
remain
-
8
-
headLen
);
if
(
rawBodyLen
>
0
)
memcpy
(
queue
->
pBuffer
,
(
char
*
)
pBody
+
remain
-
8
-
headLen
,
rawBodyLen
-
(
remain
-
8
-
headLen
));
if
(
rawBodyLen
>
0
)
memcpy
(
queue
->
pBuffer
,
(
char
*
)
pBody
+
remain
-
8
-
headLen
,
rawBodyLen
-
(
remain
-
8
-
headLen
));
queue
->
tail
=
bodyLen
-
(
remain
-
8
-
headLen
);
}
else
{
memcpy
(
queue
->
pBuffer
+
queue
->
tail
+
8
,
pHead
,
rawHeadLen
);
...
...
@@ -312,12 +313,7 @@ static void *dmConsumChildQueue(void *param) {
code
=
dmProcessNodeMsg
(
pWrapper
,
pMsg
);
if
(
code
!=
0
)
{
dError
(
"node:%s, failed to process msg:%p since %s, put into pqueue"
,
proc
->
name
,
pMsg
,
terrstr
());
SRpcMsg
rsp
=
{
.
code
=
(
terrno
!=
0
?
terrno
:
code
),
.
pCont
=
pMsg
->
info
.
rsp
,
.
contLen
=
pMsg
->
info
.
rspLen
,
.
info
=
pMsg
->
info
,
};
SRpcMsg
rsp
=
{.
code
=
(
terrno
!=
0
?
terrno
:
code
),
.
info
=
pMsg
->
info
};
dmPutToProcPQueue
(
proc
,
&
rsp
,
DND_FUNC_RSP
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
...
...
@@ -469,8 +465,18 @@ void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype) {
taosMsleep
(
retry
);
}
}
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
pMsg
->
contLen
=
0
;
}
int32_t
dmPutToProcCQueue
(
SProc
*
proc
,
SRpcMsg
*
pMsg
,
EProcFuncType
ftype
)
{
return
dmPushToProcQueue
(
proc
,
proc
->
cqueue
,
pMsg
,
ftype
);
int32_t
code
=
dmPushToProcQueue
(
proc
,
proc
->
cqueue
,
pMsg
,
ftype
);
if
(
code
==
0
)
{
dTrace
(
"msg:%p, is freed after push to cqueue"
,
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
}
return
code
;
}
source/dnode/mgmt/node_mgmt/src/dmTransport.c
浏览文件 @
22bfcc34
...
...
@@ -16,6 +16,10 @@
#define _DEFAULT_SOURCE
#include "dmMgmt.h"
static
void
dmSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
);
static
void
dmSendRsp
(
SRpcMsg
*
pMsg
);
static
void
dmBuildMnodeRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
static
inline
int32_t
dmBuildNodeMsg
(
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRpc
)
{
SRpcConnInfo
connInfo
=
{
0
};
if
(
IsReq
(
pRpc
)
&&
rpcGetConnInfo
(
pRpc
->
info
.
handle
,
&
connInfo
)
!=
0
)
{
...
...
@@ -122,27 +126,22 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
}
_OVER:
if
(
code
==
0
)
{
if
(
pWrapper
!=
NULL
&&
InParentProc
(
pWrapper
))
{
dTrace
(
"msg:%p, is freed after push to cqueue"
,
pMsg
);
taosFreeQitem
(
pMsg
);
rpcFreeCont
(
pRpc
->
pCont
);
}
}
else
{
if
(
code
!=
0
)
{
dError
(
"msg:%p, failed to process since %s"
,
pMsg
,
terrstr
());
if
(
terrno
!=
0
)
code
=
terrno
;
if
(
IsReq
(
pRpc
))
{
if
(
code
==
TSDB_CODE_NODE_NOT_DEPLOYED
||
code
==
TSDB_CODE_NODE_OFFLINE
)
{
if
(
pRpc
->
msgType
>
TDMT_MND_MSG
&&
pRpc
->
msgType
<
TDMT_VND_MSG
)
{
code
=
TSDB_CODE_NODE_REDIRECT
;
}
SRpcMsg
rsp
=
{.
code
=
code
,
.
info
=
pRpc
->
info
};
if
((
code
==
TSDB_CODE_NODE_NOT_DEPLOYED
||
code
==
TSDB_CODE_APP_NOT_READY
)
&&
pRpc
->
msgType
>
TDMT_MND_MSG
&&
pRpc
->
msgType
<
TDMT_VND_MSG
)
{
dmBuildMnodeRedirectRsp
(
pDnode
,
&
rsp
);
}
SRpcMsg
rspMsg
=
{.
code
=
code
,
.
info
=
pRpc
->
info
};
if
(
pWrapper
!=
NULL
)
{
tmsgSendRsp
(
&
rspMsg
);
dmSendRsp
(
&
rsp
);
}
else
{
rpcSendResponse
(
&
rsp
Msg
);
rpcSendResponse
(
&
rsp
);
}
}
...
...
@@ -198,13 +197,25 @@ static inline void dmSendRsp(SRpcMsg *pMsg) {
SMgmtWrapper
*
pWrapper
=
pMsg
->
info
.
wrapper
;
if
(
InChildProc
(
pWrapper
))
{
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
pMsg
,
DND_FUNC_RSP
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
else
{
rpcSendResponse
(
pMsg
);
}
}
static
void
dmBuildMnodeRedirectRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
)
{
SMEpSet
msg
=
{
0
};
dmGetMnodeEpSetForRedirect
(
&
pDnode
->
data
,
pMsg
,
&
msg
.
epSet
);
int32_t
contLen
=
tSerializeSMEpSet
(
NULL
,
0
,
&
msg
);
pMsg
->
pCont
=
rpcMallocCont
(
contLen
);
if
(
pMsg
->
pCont
==
NULL
)
{
pMsg
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
tSerializeSMEpSet
(
pMsg
->
pCont
,
contLen
,
&
msg
);
pMsg
->
contLen
=
contLen
;
}
}
static
inline
void
dmSendRedirectRsp
(
SRpcMsg
*
pMsg
,
const
SEpSet
*
pNewEpSet
)
{
SRpcMsg
rsp
=
{.
code
=
TSDB_CODE_RPC_REDIRECT
,
.
info
=
pMsg
->
info
};
SMEpSet
msg
=
{.
epSet
=
*
pNewEpSet
};
...
...
@@ -226,8 +237,6 @@ static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) {
SMgmtWrapper
*
pWrapper
=
pMsg
->
info
.
wrapper
;
if
(
InChildProc
(
pWrapper
))
{
dmPutToProcPQueue
(
&
pWrapper
->
proc
,
pMsg
,
DND_FUNC_REGIST
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
else
{
rpcRegisterBrokenLinkArg
(
pMsg
);
}
...
...
@@ -322,34 +331,3 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) {
};
return
msgCb
;
}
static
void
dmSendMnodeRedirectRsp
(
SRpcMsg
*
pMsg
)
{
SDnode
*
pDnode
=
dmInstance
();
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
&
pDnode
->
data
,
&
epSet
);
dDebug
(
"msg:%p, is redirected, num:%d use:%d"
,
pMsg
,
epSet
.
numOfEps
,
epSet
.
inUse
);
for
(
int32_t
i
=
0
;
i
<
epSet
.
numOfEps
;
++
i
)
{
dDebug
(
"mnode index:%d %s:%u"
,
i
,
epSet
.
eps
[
i
].
fqdn
,
epSet
.
eps
[
i
].
port
);
if
(
strcmp
(
epSet
.
eps
[
i
].
fqdn
,
tsLocalFqdn
)
==
0
&&
epSet
.
eps
[
i
].
port
==
tsServerPort
)
{
epSet
.
inUse
=
(
i
+
1
)
%
epSet
.
numOfEps
;
}
epSet
.
eps
[
i
].
port
=
htons
(
epSet
.
eps
[
i
].
port
);
}
SRpcMsg
rsp
=
{.
code
=
TSDB_CODE_RPC_REDIRECT
,
.
info
=
pMsg
->
info
};
SMEpSet
msg
=
{.
epSet
=
epSet
};
int32_t
contLen
=
tSerializeSMEpSet
(
NULL
,
0
,
&
msg
);
rsp
.
pCont
=
rpcMallocCont
(
contLen
);
if
(
rsp
.
pCont
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
tSerializeSMEpSet
(
rsp
.
pCont
,
contLen
,
&
msg
);
rsp
.
contLen
=
contLen
;
}
dmSendRsp
(
&
rsp
);
rpcFreeCont
(
pMsg
->
pCont
);
pMsg
->
pCont
=
NULL
;
}
source/dnode/mgmt/node_util/inc/dmUtil.h
浏览文件 @
22bfcc34
...
...
@@ -173,6 +173,7 @@ int32_t dmReadEps(SDnodeData *pData);
int32_t
dmWriteEps
(
SDnodeData
*
pData
);
void
dmUpdateEps
(
SDnodeData
*
pData
,
SArray
*
pDnodeEps
);
void
dmGetMnodeEpSet
(
SDnodeData
*
pData
,
SEpSet
*
pEpSet
);
void
dmGetMnodeEpSetForRedirect
(
SDnodeData
*
pData
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
void
dmSetMnodeEpSet
(
SDnodeData
*
pData
,
SEpSet
*
pEpSet
);
#ifdef __cplusplus
...
...
source/dnode/mgmt/node_util/src/dmEps.c
浏览文件 @
22bfcc34
...
...
@@ -314,6 +314,17 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) {
taosThreadRwlockUnlock
(
&
pData
->
lock
);
}
void
dmGetMnodeEpSetForRedirect
(
SDnodeData
*
pData
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
dmGetMnodeEpSet
(
pData
,
pEpSet
);
dDebug
(
"msg:%p, is redirected, num:%d use:%d"
,
pMsg
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
dDebug
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
eps
[
i
].
fqdn
,
pEpSet
->
eps
[
i
].
port
);
if
(
strcmp
(
pEpSet
->
eps
[
i
].
fqdn
,
tsLocalFqdn
)
==
0
&&
pEpSet
->
eps
[
i
].
port
==
tsServerPort
)
{
pEpSet
->
inUse
=
(
i
+
1
)
%
pEpSet
->
numOfEps
;
}
}
}
void
dmSetMnodeEpSet
(
SDnodeData
*
pData
,
SEpSet
*
pEpSet
)
{
taosThreadRwlockWrlock
(
&
pData
->
lock
);
pData
->
mnodeEps
=
*
pEpSet
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
22bfcc34
...
...
@@ -994,9 +994,6 @@ static int32_t mndTransSendActionMsg(SMnode *pMnode, STrans *pTrans, SArray *pAr
pAction
->
msgSent
=
0
;
pAction
->
msgReceived
=
0
;
pAction
->
errCode
=
terrno
;
if
(
terrno
==
TSDB_CODE_INVALID_PTR
||
terrno
==
TSDB_CODE_NODE_OFFLINE
)
{
rpcFreeCont
(
rpcMsg
.
pCont
);
}
mError
(
"trans:%d, action:%d not send since %s"
,
pTrans
->
id
,
action
,
terrstr
());
return
-
1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录