Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
488addaf
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看板
提交
488addaf
编写于
5月 30, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-437] fix definite lost while process show msg in mnode
上级
6482d537
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
38 deletion
+44
-38
src/mnode/inc/mnodeDef.h
src/mnode/inc/mnodeDef.h
+1
-1
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+43
-37
未找到文件。
src/mnode/inc/mnodeDef.h
浏览文件 @
488addaf
...
...
@@ -220,6 +220,7 @@ typedef struct SAcctObj {
typedef
struct
{
int8_t
type
;
int32_t
index
;
char
db
[
TSDB_DB_NAME_LEN
+
1
];
void
*
pIter
;
int16_t
numOfColumns
;
...
...
@@ -228,7 +229,6 @@ typedef struct {
int32_t
numOfReads
;
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int16_t
bytes
[
TSDB_MAX_COLUMNS
];
void
*
signature
;
uint16_t
payloadLen
;
char
payload
[];
}
SShowObj
;
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
488addaf
...
...
@@ -47,13 +47,14 @@ static int32_t mnodeProcessConnectMsg(SMnodeMsg *mnodeMsg);
static
int32_t
mnodeProcessUseMsg
(
SMnodeMsg
*
mnodeMsg
);
static
void
mnodeFreeShowObj
(
void
*
data
);
static
bool
mnode
Check
ShowObj
(
SShowObj
*
pShow
);
static
bool
mnode
Accquire
ShowObj
(
SShowObj
*
pShow
);
static
bool
mnodeCheckShowFinished
(
SShowObj
*
pShow
);
static
void
*
mnode
Save
ShowObj
(
SShowObj
*
pShow
,
int32_t
size
);
static
void
mnode
Cleanup
ShowObj
(
void
*
pShow
,
bool
forceRemove
);
static
void
*
mnode
Put
ShowObj
(
SShowObj
*
pShow
,
int32_t
size
);
static
void
mnode
Release
ShowObj
(
void
*
pShow
,
bool
forceRemove
);
extern
void
*
tsMnodeTmr
;
static
void
*
tsQhandleCache
=
NULL
;
static
void
*
tsMnodeShowCache
=
NULL
;
static
int32_t
tsShowObjIndex
=
0
;
static
SShowMetaFp
tsMnodeShowMetaFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
static
SShowRetrieveFp
tsMnodeShowRetrieveFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
...
...
@@ -64,14 +65,15 @@ int32_t mnodeInitShow() {
mnodeAddReadMsgHandle
(
TSDB_MSG_TYPE_CM_CONNECT
,
mnodeProcessConnectMsg
);
mnodeAddReadMsgHandle
(
TSDB_MSG_TYPE_CM_USE_DB
,
mnodeProcessUseMsg
);
ts
Qhandle
Cache
=
taosCacheInitWithCb
(
tsMnodeTmr
,
10
,
mnodeFreeShowObj
);
ts
MnodeShow
Cache
=
taosCacheInitWithCb
(
tsMnodeTmr
,
10
,
mnodeFreeShowObj
);
return
0
;
}
void
mnodeCleanUpShow
()
{
if
(
tsQhandleCache
!=
NULL
)
{
taosCacheCleanup
(
tsQhandleCache
);
tsQhandleCache
=
NULL
;
if
(
tsMnodeShowCache
!=
NULL
)
{
mPrint
(
"show cache is cleanup"
);
taosCacheCleanup
(
tsMnodeShowCache
);
tsMnodeShowCache
=
NULL
;
}
}
...
...
@@ -118,13 +120,12 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) {
int32_t
showObjSize
=
sizeof
(
SShowObj
)
+
htons
(
pShowMsg
->
payloadLen
);
SShowObj
*
pShow
=
(
SShowObj
*
)
calloc
(
1
,
showObjSize
);
pShow
->
signature
=
pShow
;
pShow
->
type
=
pShowMsg
->
type
;
pShow
->
payloadLen
=
htons
(
pShowMsg
->
payloadLen
);
strcpy
(
pShow
->
db
,
pShowMsg
->
db
);
memcpy
(
pShow
->
payload
,
pShowMsg
->
payload
,
pShow
->
payloadLen
);
pShow
=
mnode
Save
ShowObj
(
pShow
,
showObjSize
);
pShow
=
mnode
Put
ShowObj
(
pShow
,
showObjSize
);
if
(
pShow
==
NULL
)
{
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
...
...
@@ -132,21 +133,22 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) {
int32_t
size
=
sizeof
(
SCMShowRsp
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
+
TSDB_EXTRA_PAYLOAD_SIZE
;
SCMShowRsp
*
pShowRsp
=
rpcMallocCont
(
size
);
if
(
pShowRsp
==
NULL
)
{
mnode
FreeShowObj
(
pShow
);
mnode
ReleaseShowObj
(
pShow
,
true
);
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
}
pShowRsp
->
qhandle
=
htobe64
((
uint64_t
)
pShow
);
mTrace
(
"
show:%p,
type:%s, start to get meta"
,
pShow
,
mnodeGetShowType
(
pShowMsg
->
type
));
mTrace
(
"
%p, show
type:%s, start to get meta"
,
pShow
,
mnodeGetShowType
(
pShowMsg
->
type
));
int32_t
code
=
(
*
tsMnodeShowMetaFp
[
pShowMsg
->
type
])(
&
pShowRsp
->
tableMeta
,
pShow
,
pMsg
->
rpcMsg
.
handle
);
if
(
code
==
0
)
{
pMsg
->
rpcRsp
.
rsp
=
pShowRsp
;
pMsg
->
rpcRsp
.
len
=
sizeof
(
SCMShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
mnodeReleaseShowObj
(
pShow
,
false
);
return
TSDB_CODE_SUCCESS
;
}
else
{
mError
(
"
show:%p,
type:%s, failed to get meta, reason:%s"
,
pShow
,
mnodeGetShowType
(
pShowMsg
->
type
),
tstrerror
(
code
));
mError
(
"
%p, show
type:%s, failed to get meta, reason:%s"
,
pShow
,
mnodeGetShowType
(
pShowMsg
->
type
),
tstrerror
(
code
));
rpcFreeCont
(
pShowRsp
);
mnode
Cleanup
ShowObj
(
pShow
,
true
);
mnode
Release
ShowObj
(
pShow
,
true
);
return
code
;
}
}
...
...
@@ -159,22 +161,20 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) {
pRetrieve
->
qhandle
=
htobe64
(
pRetrieve
->
qhandle
);
SShowObj
*
pShow
=
(
SShowObj
*
)
pRetrieve
->
qhandle
;
mTrace
(
"
show:%p,
type:%s, retrieve data"
,
pShow
,
mnodeGetShowType
(
pShow
->
type
));
mTrace
(
"
%p, show
type:%s, retrieve data"
,
pShow
,
mnodeGetShowType
(
pShow
->
type
));
/*
* in case of server restart, apps may hold qhandle created by server before
* restart, which is actually invalid, therefore, signature check is required.
*/
if
(
!
mnode
Check
ShowObj
(
pShow
))
{
mError
(
"
retrieve:%p, qhandle:%p is invalid"
,
pRetrieve
,
pShow
);
if
(
!
mnode
Accquire
ShowObj
(
pShow
))
{
mError
(
"
%p, show is invalid"
,
pShow
);
return
TSDB_CODE_INVALID_QHANDLE
;
}
if
(
mnodeCheckShowFinished
(
pShow
))
{
mTrace
(
"
retrieve:%p, qhandle:%p already read finished, numOfReads:%d numOfRows:%d"
,
pRetrieve
,
pShow
,
pShow
->
numOfReads
,
pShow
->
numOfRows
);
mTrace
(
"
%p, show is already read finished, numOfReads:%d numOfRows:%d"
,
pShow
,
pShow
->
numOfReads
,
pShow
->
numOfRows
);
pShow
->
numOfReads
=
pShow
->
numOfRows
;
//mnodeCleanupShowObj(pShow, true);
//return TSDB_CODE_SUCCESS;
}
if
((
pRetrieve
->
free
&
TSDB_QUERY_TYPE_FREE_RESOURCE
)
!=
TSDB_QUERY_TYPE_FREE_RESOURCE
)
{
...
...
@@ -200,7 +200,7 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) {
if
(
rowsRead
<
0
)
{
rpcFreeCont
(
pRsp
);
mnode
Cleanup
ShowObj
(
pShow
,
false
);
mnode
Release
ShowObj
(
pShow
,
false
);
assert
(
false
);
return
TSDB_CODE_ACTION_IN_PROGRESS
;
}
...
...
@@ -211,10 +211,11 @@ static int32_t mnodeProcessRetrieveMsg(SMnodeMsg *pMsg) {
pMsg
->
rpcRsp
.
rsp
=
pRsp
;
pMsg
->
rpcRsp
.
len
=
size
;
if
(
rowsToRead
==
0
)
{
mnodeCleanupShowObj
(
pShow
,
true
);
if
(
rowsToRead
==
0
||
(
rowsRead
==
rowsToRead
))
{
pRsp
->
completed
=
1
;
mnodeReleaseShowObj
(
pShow
,
true
);
}
else
{
mnode
Cleanup
ShowObj
(
pShow
,
false
);
mnode
Release
ShowObj
(
pShow
,
false
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -318,24 +319,29 @@ static bool mnodeCheckShowFinished(SShowObj *pShow) {
return
false
;
}
static
bool
mnodeCheckShowObj
(
SShowObj
*
pShow
)
{
SShowObj
*
pSaved
=
taosCacheAcquireByData
(
tsQhandleCache
,
pShow
);
static
bool
mnodeAccquireShowObj
(
SShowObj
*
pShow
)
{
char
key
[
10
];
sprintf
(
key
,
"%d"
,
pShow
->
index
);
SShowObj
*
pSaved
=
taosCacheAcquireByName
(
tsMnodeShowCache
,
key
);
if
(
pSaved
==
pShow
)
{
mTrace
(
"%p, show is accquired from cache"
,
pShow
);
return
true
;
}
else
{
mTrace
(
"show:%p, is already released"
,
pShow
);
return
false
;
}
}
static
void
*
mnodeSaveShowObj
(
SShowObj
*
pShow
,
int32_t
size
)
{
if
(
tsQhandleCache
!=
NULL
)
{
char
key
[
24
];
sprintf
(
key
,
"show:%p"
,
pShow
);
SShowObj
*
newQhandle
=
taosCachePut
(
tsQhandleCache
,
key
,
pShow
,
size
,
60
);
static
void
*
mnodePutShowObj
(
SShowObj
*
pShow
,
int32_t
size
)
{
if
(
tsMnodeShowCache
!=
NULL
)
{
char
key
[
10
];
pShow
->
index
=
atomic_add_fetch_32
(
&
tsShowObjIndex
,
1
);
sprintf
(
key
,
"%d"
,
pShow
->
index
);
SShowObj
*
newQhandle
=
taosCachePut
(
tsMnodeShowCache
,
key
,
pShow
,
size
,
60
);
free
(
pShow
);
mTrace
(
"
show:%p, is saved
"
,
newQhandle
);
mTrace
(
"
%p, show is put into cache
"
,
newQhandle
);
return
newQhandle
;
}
...
...
@@ -345,10 +351,10 @@ static void *mnodeSaveShowObj(SShowObj *pShow, int32_t size) {
static
void
mnodeFreeShowObj
(
void
*
data
)
{
SShowObj
*
pShow
=
data
;
sdbFreeIter
(
pShow
->
pIter
);
mTrace
(
"
show:%p,
is destroyed"
,
pShow
);
mTrace
(
"
%p, show
is destroyed"
,
pShow
);
}
static
void
mnode
Cleanup
ShowObj
(
void
*
pShow
,
bool
forceRemove
)
{
mTrace
(
"
show:%p,
is released, force:%s"
,
pShow
,
forceRemove
?
"true"
:
"false"
);
taosCacheRelease
(
ts
Qhandle
Cache
,
&
pShow
,
forceRemove
);
static
void
mnode
Release
ShowObj
(
void
*
pShow
,
bool
forceRemove
)
{
mTrace
(
"
%p, show
is released, force:%s"
,
pShow
,
forceRemove
?
"true"
:
"false"
);
taosCacheRelease
(
ts
MnodeShow
Cache
,
&
pShow
,
forceRemove
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录