Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
58607175
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
58607175
编写于
4月 05, 2020
作者:
J
Jeff Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize the code in dnodeMgmt, so it can close vnode one by one when dnode cleans up
remove the RPC warnings
上级
67acb1f3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
61 addition
and
38 deletion
+61
-38
src/dnode/src/dnodeMgmt.c
src/dnode/src/dnodeMgmt.c
+35
-14
src/inc/vnode.h
src/inc/vnode.h
+2
-5
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+7
-7
src/vnode/main/src/vnodeMain.c
src/vnode/main/src/vnodeMain.c
+17
-12
未找到文件。
src/dnode/src/dnodeMgmt.c
浏览文件 @
58607175
...
...
@@ -32,6 +32,7 @@
#include "vnode.h"
static
int32_t
dnodeOpenVnodes
();
static
void
dnodeCloseVnodes
();
static
int32_t
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
dnodeProcessDropVnodeMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
dnodeProcessAlterVnodeMsg
(
SRpcMsg
*
pMsg
);
...
...
@@ -64,10 +65,6 @@ int32_t dnodeInitMgmt() {
return
-
1
;
}
if
(
vnodeInitModule
()
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
}
int32_t
code
=
dnodeOpenVnodes
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
-
1
;
...
...
@@ -88,7 +85,7 @@ void dnodeCleanupMgmt() {
tsDnodeTmr
=
NULL
;
}
vnodeCleanupModule
();
dnodeCloseVnodes
();
}
void
dnodeMgmt
(
SRpcMsg
*
pMsg
)
{
...
...
@@ -107,7 +104,7 @@ void dnodeMgmt(SRpcMsg *pMsg) {
rpcFreeCont
(
pMsg
->
pCont
);
}
static
int
32_t
dnodeOpenVnodes
(
)
{
static
int
dnodeGetVnodeList
(
int32_t
vnodeList
[]
)
{
DIR
*
dir
=
opendir
(
tsVnodeDir
);
if
(
dir
==
NULL
)
{
return
TSDB_CODE_NO_WRITE_ACCESS
;
...
...
@@ -122,18 +119,42 @@ static int32_t dnodeOpenVnodes() {
int32_t
vnode
=
atoi
(
de
->
d_name
+
5
);
if
(
vnode
==
0
)
continue
;
char
vnodeDir
[
TSDB_FILENAME_LEN
*
3
];
snprintf
(
vnodeDir
,
TSDB_FILENAME_LEN
*
3
,
"%s/%s"
,
tsVnodeDir
,
de
->
d_name
);
int32_t
code
=
vnodeOpen
(
vnode
,
vnodeDir
);
if
(
code
==
0
)
{
numOfVnodes
++
;
}
vnodeList
[
numOfVnodes
]
=
vnode
;
numOfVnodes
++
;
}
}
closedir
(
dir
);
dPrint
(
"dnode mgmt is opened, vnodes:%d"
,
numOfVnodes
);
return
TSDB_CODE_SUCCESS
;
return
numOfVnodes
;
}
static
int32_t
dnodeOpenVnodes
()
{
char
vnodeDir
[
TSDB_FILENAME_LEN
*
3
];
int
failed
=
0
;
int32_t
*
vnodeList
=
(
int32_t
*
)
malloc
(
sizeof
(
int32_t
)
*
10000
);
int
numOfVnodes
=
dnodeGetVnodeList
(
vnodeList
);
for
(
int
i
=
0
;
i
<
numOfVnodes
;
++
i
)
{
snprintf
(
vnodeDir
,
TSDB_FILENAME_LEN
*
3
,
"%s/vnode%d"
,
tsVnodeDir
,
vnodeList
[
i
]);
if
(
vnodeOpen
(
vnodeList
[
i
],
vnodeDir
)
<
0
)
failed
++
;
}
free
(
vnodeList
);
dPrint
(
"there are total vnodes:%d, failed to open:%d"
,
numOfVnodes
,
failed
);
return
TSDB_CODE_SUCCESS
;
}
static
void
dnodeCloseVnodes
()
{
int32_t
*
vnodeList
=
(
int32_t
*
)
malloc
(
sizeof
(
int32_t
)
*
10000
);
int
numOfVnodes
=
dnodeGetVnodeList
(
vnodeList
);
for
(
int
i
=
0
;
i
<
numOfVnodes
;
++
i
)
vnodeClose
(
vnodeList
[
i
]);
free
(
vnodeList
);
dPrint
(
"total vnodes:%d are all closed"
,
numOfVnodes
);
}
static
int32_t
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
...
...
src/inc/vnode.h
浏览文件 @
58607175
...
...
@@ -25,13 +25,10 @@ typedef struct {
void
*
rsp
;
}
SRspRet
;
int32_t
vnodeInitModule
();
void
vnodeCleanupModule
();
int32_t
vnodeCreate
(
SMDCreateVnodeMsg
*
pVnodeCfg
);
int32_t
vnodeDrop
(
int32_t
vgId
);
int32_t
vnodeOpen
(
int32_t
v
node
,
char
*
rootDir
);
int32_t
vnodeClose
(
void
*
pVnode
);
int32_t
vnodeOpen
(
int32_t
v
gId
,
char
*
rootDir
);
int32_t
vnodeClose
(
int32_t
vgId
);
void
vnodeRelease
(
void
*
pVnode
);
void
*
vnodeGetVnode
(
int32_t
vgId
);
...
...
src/rpc/src/rpcMain.c
浏览文件 @
58607175
...
...
@@ -263,7 +263,6 @@ void *rpcOpen(SRpcInit *pInit) {
}
if
(
pRpc
->
connType
==
TAOS_CONN_SERVER
)
{
// pRpc->hash = taosInitStrHash(pRpc->sessions, sizeof(pRpc), taosHashString);
pRpc
->
hash
=
taosHashInit
(
pRpc
->
sessions
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
);
if
(
pRpc
->
hash
==
NULL
)
{
tError
(
"%s failed to init string hash"
,
pRpc
->
label
);
...
...
@@ -535,8 +534,7 @@ static void rpcCloseConn(void *thandle) {
if
(
pRpc
->
connType
==
TAOS_CONN_SERVER
)
{
char
hashstr
[
40
]
=
{
0
};
size_t
size
=
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pConn
->
peerIp
,
pConn
->
linkUid
,
pConn
->
peerId
,
pConn
->
connType
);
// taosDeleteStrHash(pRpc->hash, hashstr);
// taosHashRemove(pRpc->hash, hashstr, size);
taosHashRemove
(
pRpc
->
hash
,
hashstr
,
size
);
rpcFreeMsg
(
pConn
->
pRspMsg
);
// it may have a response msg saved, but not request msg
pConn
->
pRspMsg
=
NULL
;
...
...
@@ -588,7 +586,6 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
size_t
size
=
sprintf
(
hashstr
,
"%x:%x:%x:%d"
,
pRecv
->
ip
,
pHead
->
linkUid
,
pHead
->
sourceId
,
pRecv
->
connType
);
// check if it is already allocated
// SRpcConn **ppConn = (SRpcConn **)(taosGetStrHashData(pRpc->hash, hashstr));
SRpcConn
**
ppConn
=
(
SRpcConn
**
)(
taosHashGet
(
pRpc
->
hash
,
hashstr
,
size
));
if
(
ppConn
)
pConn
=
*
ppConn
;
if
(
pConn
)
return
pConn
;
...
...
@@ -621,7 +618,6 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) {
pConn
->
localPort
=
(
pRpc
->
localPort
+
pRpc
->
index
);
}
// taosAddStrHash(pRpc->hash, hashstr, (char *)&pConn);
taosHashPut
(
pRpc
->
hash
,
hashstr
,
size
,
(
char
*
)
&
pConn
,
POINTER_BYTES
);
tTrace
(
"%s %p, rpc connection is allocated, sid:%d id:%s port:%u"
,
...
...
@@ -834,13 +830,15 @@ static void rpcProcessBrokenLink(SRpcConn *pConn) {
if
(
pConn
->
inType
)
{
// if there are pending request, notify the app
tTrace
(
"%s %p, connection is gone, notify the app"
,
pRpc
->
label
,
pConn
);
/*
SRpcMsg rpcMsg;
rpcMsg.pCont = NULL;
rpcMsg.contLen = 0;
rpcMsg.handle = pConn;
rpcMsg.msgType = pConn->inType;
rpcMsg.code = TSDB_CODE_NETWORK_UNAVAIL;
// (*(pRpc->cfp))(&rpcMsg);
(*(pRpc->cfp))(&rpcMsg);
*/
}
rpcCloseConn
(
pConn
);
...
...
@@ -1163,13 +1161,15 @@ static void rpcProcessIdleTimer(void *param, void *tmrId) {
if
(
pConn
->
inType
&&
pRpc
->
cfp
)
{
// if there are pending request, notify the app
tTrace
(
"%s %p, notify the app, connection is gone"
,
pRpc
->
label
,
pConn
);
/*
SRpcMsg rpcMsg;
rpcMsg.pCont = NULL;
rpcMsg.contLen = 0;
rpcMsg.handle = pConn;
rpcMsg.msgType = pConn->inType;
rpcMsg.code = TSDB_CODE_NETWORK_UNAVAIL;
// (*(pRpc->cfp))(&rpcMsg);
(*(pRpc->cfp))(&rpcMsg);
*/
}
rpcCloseConn
(
pConn
);
}
else
{
...
...
src/vnode/main/src/vnodeMain.c
浏览文件 @
58607175
...
...
@@ -33,27 +33,22 @@ static void *tsDnodeVnodesHash;
static
void
vnodeCleanUp
(
SVnodeObj
*
pVnode
);
static
void
vnodeBuildVloadMsg
(
char
*
pNode
,
void
*
param
);
int32_t
vnodeInitModule
()
{
static
int
tsOpennedVnodes
;
static
pthread_once_t
vnodeModuleInit
=
PTHREAD_ONCE_INIT
;
static
void
vnodeInit
()
{
vnodeInitWriteFp
();
tsDnodeVnodesHash
=
taosInitIntHash
(
TSDB_MAX_VNODES
,
sizeof
(
SVnodeObj
),
taosHashInt
);
if
(
tsDnodeVnodesHash
==
NULL
)
{
dError
(
"failed to init vnode list"
);
return
-
1
;
}
return
0
;
}
typedef
void
(
*
CleanupFp
)(
char
*
);
void
vnodeCleanupModule
()
{
taosCleanUpIntHashWithFp
(
tsDnodeVnodesHash
,
(
CleanupFp
)
vnodeClose
);
taosCleanUpIntHash
(
tsDnodeVnodesHash
);
}
int32_t
vnodeCreate
(
SMDCreateVnodeMsg
*
pVnodeCfg
)
{
int32_t
code
;
pthread_once
(
&
vnodeModuleInit
,
vnodeInit
);
SVnodeObj
*
pTemp
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
pVnodeCfg
->
cfg
.
vgId
);
...
...
@@ -116,6 +111,7 @@ int32_t vnodeDrop(int32_t vgId) {
int32_t
vnodeOpen
(
int32_t
vnode
,
char
*
rootDir
)
{
char
temp
[
TSDB_FILENAME_LEN
];
pthread_once
(
&
vnodeModuleInit
,
vnodeInit
);
SVnodeObj
vnodeObj
=
{
0
};
vnodeObj
.
vgId
=
vnode
;
...
...
@@ -147,11 +143,14 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
pVnode
->
status
=
VN_STATUS_READY
;
dTrace
(
"pVnode:%p vgId:%d, vnode is opened in %s"
,
pVnode
,
pVnode
->
vgId
,
rootDir
);
tsOpennedVnodes
++
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
vnodeClose
(
void
*
param
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
param
;
int32_t
vnodeClose
(
int32_t
vgId
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
taosGetIntHashData
(
tsDnodeVnodesHash
,
vgId
);
if
(
pVnode
==
NULL
)
return
0
;
dTrace
(
"pVnode:%p vgId:%d, vnode will be closed"
,
pVnode
,
pVnode
->
vgId
);
pVnode
->
status
=
VN_STATUS_CLOSING
;
...
...
@@ -183,6 +182,12 @@ void vnodeRelease(void *pVnodeRaw) {
}
dTrace
(
"pVnode:%p vgId:%d, vnode is released"
,
pVnode
,
pVnode
->
vgId
);
tsOpennedVnodes
--
;
if
(
tsOpennedVnodes
<=
0
)
{
taosCleanUpIntHash
(
tsDnodeVnodesHash
);
vnodeModuleInit
=
PTHREAD_ONCE_INIT
;
}
}
void
*
vnodeGetVnode
(
int32_t
vgId
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录