Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7a070dfa
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
7a070dfa
编写于
2月 20, 2023
作者:
K
kailixu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: code optimization
上级
a7ad0ffc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
13 deletion
+51
-13
src/mnode/inc/mnodeTable.h
src/mnode/inc/mnodeTable.h
+1
-0
src/mnode/src/mnodeInt.c
src/mnode/src/mnodeInt.c
+6
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+44
-12
未找到文件。
src/mnode/inc/mnodeTable.h
浏览文件 @
7a070dfa
...
@@ -36,6 +36,7 @@ void mnodeCancelGetNextSuperTable(void *pIter);
...
@@ -36,6 +36,7 @@ void mnodeCancelGetNextSuperTable(void *pIter);
void
mnodeDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllChildTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllSuperTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllSuperTables
(
SDbObj
*
pDropDb
);
void
mnodeDropAllChildTablesInVgroups
(
SVgObj
*
pVgroup
);
void
mnodeDropAllChildTablesInVgroups
(
SVgObj
*
pVgroup
);
bool
mnodeFreeMetaSyncDropTables
(
STableObj
*
pTable
);
int32_t
mnodeCompactTables
();
int32_t
mnodeCompactTables
();
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/mnode/src/mnodeInt.c
浏览文件 @
7a070dfa
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "os.h"
#include "os.h"
#include "taosmsg.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "taoserror.h"
#include "tglobal.h"
#include "trpc.h"
#include "trpc.h"
#include "tqueue.h"
#include "tqueue.h"
#include "mnode.h"
#include "mnode.h"
...
@@ -68,7 +69,11 @@ void mnodeCleanupMsg(SMnodeMsg *pMsg) {
...
@@ -68,7 +69,11 @@ void mnodeCleanupMsg(SMnodeMsg *pMsg) {
if
(
pMsg
->
pUser
)
mnodeDecUserRef
(
pMsg
->
pUser
);
if
(
pMsg
->
pUser
)
mnodeDecUserRef
(
pMsg
->
pUser
);
if
(
pMsg
->
pDb
)
mnodeDecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pDb
)
mnodeDecDbRef
(
pMsg
->
pDb
);
if
(
pMsg
->
pVgroup
)
mnodeDecVgroupRef
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pVgroup
)
mnodeDecVgroupRef
(
pMsg
->
pVgroup
);
if
(
pMsg
->
pTable
)
mnodeDecTableRef
(
pMsg
->
pTable
);
if
(
pMsg
->
pTable
)
{
if
(
!
tsMetaSyncOption
||
!
mnodeFreeMetaSyncDropTables
(
pMsg
->
pTable
))
{
mnodeDecTableRef
(
pMsg
->
pTable
);
}
}
if
(
pMsg
->
pSTable
)
mnodeDecTableRef
(
pMsg
->
pSTable
);
if
(
pMsg
->
pSTable
)
mnodeDecTableRef
(
pMsg
->
pSTable
);
if
(
pMsg
->
pAcct
)
mnodeDecAcctRef
(
pMsg
->
pAcct
);
if
(
pMsg
->
pAcct
)
mnodeDecAcctRef
(
pMsg
->
pAcct
);
if
(
pMsg
->
pDnode
)
mnodeDecDnodeRef
(
pMsg
->
pDnode
);
if
(
pMsg
->
pDnode
)
mnodeDecDnodeRef
(
pMsg
->
pDnode
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
7a070dfa
...
@@ -52,7 +52,8 @@
...
@@ -52,7 +52,8 @@
// informal
// informal
#define META_SYNC_TABLE_NAME "_taos_meta_sync_table_name_taos_"
#define META_SYNC_TABLE_NAME "_taos_meta_sync_table_name_taos_"
#define META_SYNC_TABLE_NAME_LEN 32
#define META_SYNC_TABLE_NAME_LEN 32
#define META_SYNC_DROP_TABLE "_taos_meta_sync_drop_table_taos_"
#define META_SYNC_DROP_MNDTB "_taos_meta_sync_drop_mndtb_taos_"
#define META_SYNC_DROP_VNDTB "_taos_meta_sync_drop_vndtb_taos_"
#define META_SYNC_DROP_TABLE_LEN 32
#define META_SYNC_DROP_TABLE_LEN 32
// informal
// informal
...
@@ -787,6 +788,7 @@ void mnodeDecTableRef(void *p1) {
...
@@ -787,6 +788,7 @@ void mnodeDecTableRef(void *p1) {
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
sdbDecRef
(
tsSuperTableSdb
,
pTable
);
sdbDecRef
(
tsSuperTableSdb
,
pTable
);
}
else
{
}
else
{
mInfo
(
"%s:%d @@@ pTable:%p tableId:%s"
,
__func__
,
__LINE__
,
pTable
,
pTable
->
tableId
);
sdbDecRef
(
tsChildTableSdb
,
pTable
);
sdbDecRef
(
tsChildTableSdb
,
pTable
);
}
}
}
}
...
@@ -1018,7 +1020,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -1018,7 +1020,7 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
}
}
#endif
#endif
if
(
tsMetaSyncOption
&&
strstr
(
pDrop
->
name
,
META_SYNC_DROP_
TABLE
))
{
if
(
tsMetaSyncOption
&&
strstr
(
pDrop
->
name
,
META_SYNC_DROP_
VNDTB
))
{
return
mnodeProcessMetaSyncDropTableMsg
(
pMsg
);
return
mnodeProcessMetaSyncDropTableMsg
(
pMsg
);
}
}
...
@@ -2411,7 +2413,7 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
...
@@ -2411,7 +2413,7 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
}
}
if
(
tsMetaSyncOption
)
{
if
(
tsMetaSyncOption
)
{
if
(
strstr
((
const
char
*
)((
SCTableObj
*
)
pMsg
->
pTable
->
tableId
),
META_SYNC_TABLE_NAME
))
{
if
(
strstr
((
const
char
*
)((
SCTableObj
*
)
pMsg
->
pTable
->
tableId
),
META_SYNC_DROP_MNDTB
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -2444,6 +2446,17 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
...
@@ -2444,6 +2446,17 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
return
code
;
return
code
;
}
}
bool
mnodeFreeMetaSyncDropTables
(
STableObj
*
pObj
)
{
SCTableObj
*
pCTableObj
=
(
SCTableObj
*
)
pObj
;
if
(
pCTableObj
->
refCount
==
INT32_MIN
&&
pCTableObj
->
reserved0
[
0
]
==
INT8_MIN
&&
pCTableObj
->
reserved0
[
1
]
==
INT8_MAX
)
{
tfree
(
pCTableObj
->
info
.
tableId
);
tfree
(
pCTableObj
);
return
true
;
}
return
false
;
}
static
int32_t
mnodeProcessMetaSyncDropTableMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessMetaSyncDropTableMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
int32_t
vgId
=
-
1
;
int32_t
vgId
=
-
1
;
...
@@ -2454,19 +2467,26 @@ static int32_t mnodeProcessMetaSyncDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -2454,19 +2467,26 @@ static int32_t mnodeProcessMetaSyncDropTableMsg(SMnodeMsg *pMsg) {
int32_t
fnum
=
0
;
int32_t
fnum
=
0
;
char
*
fStr
=
NULL
;
char
*
fStr
=
NULL
;
char
**
fnameList
=
NULL
;
char
**
fnameList
=
NULL
;
SCTableObj
ctableObj
=
{.
info
=
{
0
}}
;
SCTableObj
*
pTable
=
NULL
;
SCMDropTableMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SCMDropTableMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
pMsg
->
pTable
=
(
struct
STableObj
*
)
&
ctableObj
;
SCTableObj
*
pTable
=
(
SCTableObj
*
)
pMsg
->
pTable
;
// META_SYNC_DROP_TABLE: _taos_meta_sync_drop_table_taos_tableType_vgId_uid_tid_tbName;
pTable
=
calloc
(
1
,
sizeof
(
SCTableObj
));
if
(
!
pTable
)
{
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
goto
_exit
;
}
ASSERT
(
pMsg
->
pTable
==
NULL
);
pMsg
->
pTable
=
(
struct
STableObj
*
)
pTable
;
// META_SYNC_DROP_VNDTB: _taos_meta_sync_drop_vndtb_taos_tableType_vgId_uid_tid_tbName;
fStr
=
strndup
(
pDrop
->
name
,
strlen
(
pDrop
->
name
));
fStr
=
strndup
(
pDrop
->
name
,
strlen
(
pDrop
->
name
));
if
(
!
fStr
)
{
if
(
!
fStr
)
{
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
goto
_exit
;
goto
_exit
;
}
}
fnameList
=
strsplit
(
fStr
,
"."
,
&
fnum
);
fnameList
=
strsplit
(
fStr
,
"."
,
&
fnum
);
if
(
fnum
>
6
&&
0
==
strncmp
(
fnameList
[
2
],
META_SYNC_DROP_
TABLE
,
META_SYNC_DROP_TABLE_LEN
))
{
if
(
fnum
>
6
&&
0
==
strncmp
(
fnameList
[
2
],
META_SYNC_DROP_
VNDTB
,
META_SYNC_DROP_TABLE_LEN
))
{
tableType
=
atoi
(
fnameList
[
3
]);
tableType
=
atoi
(
fnameList
[
3
]);
if
(
errno
!=
0
)
{
if
(
errno
!=
0
)
{
code
=
TAOS_SYSTEM_ERROR
(
errno
);
code
=
TAOS_SYSTEM_ERROR
(
errno
);
...
@@ -2492,22 +2512,29 @@ static int32_t mnodeProcessMetaSyncDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -2492,22 +2512,29 @@ static int32_t mnodeProcessMetaSyncDropTableMsg(SMnodeMsg *pMsg) {
strncpy
(
tbName
+
strlen
(
tbName
),
fnameList
[
1
],
TSDB_TABLE_FNAME_LEN
-
strlen
(
tbName
));
strncpy
(
tbName
+
strlen
(
tbName
),
fnameList
[
1
],
TSDB_TABLE_FNAME_LEN
-
strlen
(
tbName
));
tbName
[
strlen
(
tbName
)]
=
'.'
;
tbName
[
strlen
(
tbName
)]
=
'.'
;
if
(
strchr
(
pDrop
->
name
,
' '
))
{
if
(
strchr
(
pDrop
->
name
,
' '
))
{
strncpy
(
tbName
+
strlen
(
tbName
),
pDrop
->
name
+
1
,
TSDB_TABLE_FNAME_LEN
-
strlen
(
tbName
));
strncpy
(
tbName
+
strlen
(
tbName
),
strchr
(
pDrop
->
name
,
' '
)
+
1
,
TSDB_TABLE_FNAME_LEN
-
strlen
(
tbName
));
}
}
}
else
{
}
else
{
code
=
TSDB_CODE_
TSC
_INVALID_TABLE_NAME
;
code
=
TSDB_CODE_
MND
_INVALID_TABLE_NAME
;
goto
_exit
;
goto
_exit
;
}
}
if
(
tableType
!=
TSDB_CHILD_TABLE
&&
tableType
!=
TSDB_NORMAL_TABLE
)
{
if
(
tableType
!=
TSDB_CHILD_TABLE
&&
tableType
!=
TSDB_NORMAL_TABLE
)
{
code
=
TSDB_CODE_
TSC
_INVALID_TABLE_NAME
;
code
=
TSDB_CODE_
MND
_INVALID_TABLE_NAME
;
goto
_exit
;
goto
_exit
;
}
}
pTable
->
info
.
type
=
TSDB_CHILD_TABLE
;
pTable
->
info
.
type
=
TSDB_CHILD_TABLE
;
pTable
->
info
.
tableId
=
tbName
;
pTable
->
info
.
tableId
=
malloc
(
strlen
(
tbName
)
+
1
);
if
(
!
pTable
->
info
.
tableId
)
{
code
=
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
tstrncpy
(
pTable
->
info
.
tableId
,
tbName
,
strlen
(
tbName
)
+
1
);
pTable
->
uid
=
uid
;
pTable
->
uid
=
uid
;
pTable
->
tid
=
tid
;
pTable
->
tid
=
tid
;
pTable
->
vgId
=
vgId
;
pTable
->
vgId
=
vgId
;
pTable
->
refCount
=
INT32_MIN
;
pTable
->
reserved0
[
0
]
=
INT8_MIN
;
pTable
->
reserved0
[
1
]
=
INT8_MAX
;
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
if
(
pMsg
->
pVgroup
==
NULL
)
{
...
@@ -2521,9 +2548,14 @@ static int32_t mnodeProcessMetaSyncDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -2521,9 +2548,14 @@ static int32_t mnodeProcessMetaSyncDropTableMsg(SMnodeMsg *pMsg) {
_exit:
_exit:
if
(
code
)
{
if
(
code
)
{
if
(
pTable
)
{
tfree
(
pTable
->
info
.
tableId
);
tfree
(
pTable
);
}
mError
(
"%s:%d, msg:%p, app:%p table:%s, failed to drop table since %s"
,
__func__
,
__LINE__
,
pMsg
,
mError
(
"%s:%d, msg:%p, app:%p table:%s, failed to drop table since %s"
,
__func__
,
__LINE__
,
pMsg
,
pMsg
->
rpcMsg
.
ahandle
,
pDrop
->
name
,
tstrerror
(
code
));
pMsg
->
rpcMsg
.
ahandle
,
pDrop
->
name
,
tstrerror
(
code
));
}
}
tfree
(
fStr
);
tfree
(
fStr
);
tfree
(
fnameList
);
tfree
(
fnameList
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录