Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b897d803
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b897d803
编写于
11月 28, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-2264
上级
521ae131
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
75 addition
and
30 deletion
+75
-30
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+5
-2
src/mnode/src/mnodeAcct.c
src/mnode/src/mnodeAcct.c
+4
-2
src/mnode/src/mnodeCluster.c
src/mnode/src/mnodeCluster.c
+5
-3
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+4
-2
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+4
-2
src/mnode/src/mnodeMain.c
src/mnode/src/mnodeMain.c
+1
-0
src/mnode/src/mnodeMnode.c
src/mnode/src/mnodeMnode.c
+4
-2
src/mnode/src/mnodeProfile.c
src/mnode/src/mnodeProfile.c
+0
-1
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+30
-5
src/mnode/src/mnodeShow.c
src/mnode/src/mnodeShow.c
+0
-1
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+10
-6
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+4
-2
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+4
-2
未找到文件。
src/mnode/inc/mnodeSdb.h
浏览文件 @
b897d803
...
...
@@ -79,10 +79,13 @@ typedef struct {
int32_t
(
*
fpRestored
)();
}
SSdbTableDesc
;
int32_t
sdbInitRef
();
void
sdbCleanUpRef
();
int32_t
sdbInit
();
void
sdbCleanUp
();
void
*
sdbOpenTable
(
SSdbTableDesc
*
desc
);
void
sdbCloseTable
(
void
*
handle
);
int64_t
sdbOpenTable
(
SSdbTableDesc
*
desc
);
void
sdbCloseTable
(
int64_t
rid
);
void
*
sdbGetTableByRid
(
int64_t
rid
);
bool
sdbIsMaster
();
bool
sdbIsServing
();
void
sdbUpdateMnodeRoles
();
...
...
src/mnode/src/mnodeAcct.c
浏览文件 @
b897d803
...
...
@@ -26,6 +26,7 @@
#include "mnodeUser.h"
#include "mnodeVgroup.h"
int64_t
tsAcctRid
=
-
1
;
void
*
tsAcctSdb
=
NULL
;
static
int32_t
tsAcctUpdateSize
;
static
int32_t
mnodeCreateRootAcct
();
...
...
@@ -114,7 +115,8 @@ int32_t mnodeInitAccts() {
.
fpRestored
=
mnodeAcctActionRestored
};
tsAcctSdb
=
sdbOpenTable
(
&
desc
);
tsAcctRid
=
sdbOpenTable
(
&
desc
);
tsAcctSdb
=
sdbGetTableByRid
(
tsAcctRid
);
if
(
tsAcctSdb
==
NULL
)
{
mError
(
"table:%s, failed to create hash"
,
desc
.
name
);
return
-
1
;
...
...
@@ -126,7 +128,7 @@ int32_t mnodeInitAccts() {
void
mnodeCleanupAccts
()
{
acctCleanUp
();
sdbCloseTable
(
tsAcct
Sdb
);
sdbCloseTable
(
tsAcct
Rid
);
tsAcctSdb
=
NULL
;
}
...
...
src/mnode/src/mnodeCluster.c
浏览文件 @
b897d803
...
...
@@ -24,6 +24,7 @@
#include "mnodeShow.h"
#include "tglobal.h"
int64_t
tsClusterRid
=
-
1
;
static
void
*
tsClusterSdb
=
NULL
;
static
int32_t
tsClusterUpdateSize
;
static
char
tsClusterId
[
TSDB_CLUSTER_ID_LEN
];
...
...
@@ -101,9 +102,10 @@ int32_t mnodeInitCluster() {
.
fpRestored
=
mnodeClusterActionRestored
};
tsClusterSdb
=
sdbOpenTable
(
&
desc
);
tsClusterRid
=
sdbOpenTable
(
&
desc
);
tsClusterSdb
=
sdbGetTableByRid
(
tsClusterRid
);
if
(
tsClusterSdb
==
NULL
)
{
mError
(
"table:%s,
failed to create hash"
,
desc
.
name
);
mError
(
"table:%s,
rid:%"
PRId64
", failed to create hash"
,
desc
.
name
,
tsClusterRid
);
return
-
1
;
}
...
...
@@ -116,7 +118,7 @@ int32_t mnodeInitCluster() {
}
void
mnodeCleanupCluster
()
{
sdbCloseTable
(
tsCluster
Sdb
);
sdbCloseTable
(
tsCluster
Rid
);
tsClusterSdb
=
NULL
;
}
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
b897d803
...
...
@@ -38,6 +38,7 @@
#include "mnodeVgroup.h"
#define VG_LIST_SIZE 8
int64_t
tsDbRid
=
-
1
;
static
void
*
tsDbSdb
=
NULL
;
static
int32_t
tsDbUpdateSize
;
...
...
@@ -160,7 +161,8 @@ int32_t mnodeInitDbs() {
.
fpRestored
=
mnodeDbActionRestored
};
tsDbSdb
=
sdbOpenTable
(
&
desc
);
tsDbRid
=
sdbOpenTable
(
&
desc
);
tsDbSdb
=
sdbGetTableByRid
(
tsDbRid
);
if
(
tsDbSdb
==
NULL
)
{
mError
(
"failed to init db data"
);
return
-
1
;
...
...
@@ -496,7 +498,7 @@ void mnodeRemoveVgroupFromDb(SVgObj *pVgroup) {
}
void
mnodeCleanupDbs
()
{
sdbCloseTable
(
tsDb
Sdb
);
sdbCloseTable
(
tsDb
Rid
);
tsDbSdb
=
NULL
;
}
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
b897d803
...
...
@@ -39,6 +39,7 @@
#include "mnodeCluster.h"
int32_t
tsAccessSquence
=
0
;
int64_t
tsDnodeRid
=
-
1
;
static
void
*
tsDnodeSdb
=
NULL
;
static
int32_t
tsDnodeUpdateSize
=
0
;
extern
void
*
tsMnodeSdb
;
...
...
@@ -187,7 +188,8 @@ int32_t mnodeInitDnodes() {
.
fpRestored
=
mnodeDnodeActionRestored
};
tsDnodeSdb
=
sdbOpenTable
(
&
desc
);
tsDnodeRid
=
sdbOpenTable
(
&
desc
);
tsDnodeSdb
=
sdbGetTableByRid
(
tsDnodeRid
);
if
(
tsDnodeSdb
==
NULL
)
{
mError
(
"failed to init dnodes data"
);
return
-
1
;
...
...
@@ -213,7 +215,7 @@ int32_t mnodeInitDnodes() {
}
void
mnodeCleanupDnodes
()
{
sdbCloseTable
(
tsDnode
Sdb
);
sdbCloseTable
(
tsDnode
Rid
);
pthread_mutex_destroy
(
&
tsDnodeEpsMutex
);
free
(
tsDnodeEps
);
tsDnodeEps
=
NULL
;
...
...
src/mnode/src/mnodeMain.c
浏览文件 @
b897d803
...
...
@@ -47,6 +47,7 @@ void *tsMnodeTmr = NULL;
static
bool
tsMgmtIsRunning
=
false
;
static
const
SMnodeComponent
tsMnodeComponents
[]
=
{
{
"sdbref"
,
sdbInitRef
,
sdbCleanUpRef
},
{
"profile"
,
mnodeInitProfile
,
mnodeCleanupProfile
},
{
"cluster"
,
mnodeInitCluster
,
mnodeCleanupCluster
},
{
"accts"
,
mnodeInitAccts
,
mnodeCleanupAccts
},
...
...
src/mnode/src/mnodeMnode.c
浏览文件 @
b897d803
...
...
@@ -34,6 +34,7 @@
#include "mnodeUser.h"
#include "mnodeVgroup.h"
int64_t
tsMnodeRid
=
-
1
;
static
void
*
tsMnodeSdb
=
NULL
;
static
int32_t
tsMnodeUpdateSize
=
0
;
static
SRpcEpSet
tsMnodeEpSetForShell
;
...
...
@@ -153,7 +154,8 @@ int32_t mnodeInitMnodes() {
.
fpRestored
=
mnodeMnodeActionRestored
};
tsMnodeSdb
=
sdbOpenTable
(
&
desc
);
tsMnodeRid
=
sdbOpenTable
(
&
desc
);
tsMnodeSdb
=
sdbGetTableByRid
(
tsMnodeRid
);
if
(
tsMnodeSdb
==
NULL
)
{
mError
(
"failed to init mnodes data"
);
return
-
1
;
...
...
@@ -168,7 +170,7 @@ int32_t mnodeInitMnodes() {
}
void
mnodeCleanupMnodes
()
{
sdbCloseTable
(
tsMnode
Sdb
);
sdbCloseTable
(
tsMnode
Rid
);
tsMnodeSdb
=
NULL
;
mnodeMnodeDestroyLock
();
}
...
...
src/mnode/src/mnodeProfile.c
浏览文件 @
b897d803
...
...
@@ -34,7 +34,6 @@
#define QUERY_ID_SIZE 20
#define QUERY_STREAM_SAVE_SIZE 20
extern
void
*
tsMnodeTmr
;
static
SCacheObj
*
tsMnodeConnCache
=
NULL
;
static
int32_t
tsConnIndex
=
0
;
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
b897d803
...
...
@@ -18,6 +18,7 @@
#include "taoserror.h"
#include "hash.h"
#include "tutil.h"
#include "tref.h"
#include "tbalance.h"
#include "tqueue.h"
#include "twal.h"
...
...
@@ -98,6 +99,7 @@ typedef struct {
SSdbWorker
*
worker
;
}
SSdbWorkerPool
;
int32_t
tsSdbRid
;
extern
void
*
tsMnodeTmr
;
static
void
*
tsSdbTmr
;
static
SSdbMgmt
tsSdbMgmt
=
{
0
};
...
...
@@ -118,6 +120,7 @@ static void sdbFreeQueue();
static
int32_t
sdbInsertHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbUpdateHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
int32_t
sdbDeleteHash
(
SSdbTable
*
pTable
,
SSdbRow
*
pRow
);
static
void
sdbCloseTableObj
(
void
*
handle
);
int32_t
sdbGetId
(
void
*
pTable
)
{
return
((
SSdbTable
*
)
pTable
)
->
autoIndex
;
...
...
@@ -385,6 +388,17 @@ void sdbUpdateSync(void *pMnodes) {
sdbUpdateMnodeRoles
();
}
int32_t
sdbInitRef
()
{
tsSdbRid
=
taosOpenRef
(
10
,
sdbCloseTableObj
);
if
(
tsSdbRid
<=
0
)
{
sdbError
(
"failed to init sdb ref"
);
return
-
1
;
}
return
0
;
}
void
sdbCleanUpRef
()
{
taosCloseRef
(
tsSdbRid
);
}
int32_t
sdbInit
()
{
pthread_mutex_init
(
&
tsSdbMgmt
.
mutex
,
NULL
);
...
...
@@ -423,7 +437,7 @@ void sdbCleanUp() {
walClose
(
tsSdbMgmt
.
wal
);
tsSdbMgmt
.
wal
=
NULL
;
}
pthread_mutex_destroy
(
&
tsSdbMgmt
.
mutex
);
}
...
...
@@ -801,10 +815,10 @@ void sdbFreeIter(void *tparam, void *pIter) {
taosHashCancelIterate
(
pTable
->
iHandle
,
pIter
);
}
void
*
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
int64_t
sdbOpenTable
(
SSdbTableDesc
*
pDesc
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
calloc
(
1
,
sizeof
(
SSdbTable
));
if
(
pTable
==
NULL
)
return
NULL
;
if
(
pTable
==
NULL
)
return
-
1
;
pthread_mutex_init
(
&
pTable
->
mutex
,
NULL
);
tstrncpy
(
pTable
->
name
,
pDesc
->
name
,
SDB_TABLE_LEN
);
...
...
@@ -829,10 +843,21 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
tsSdbMgmt
.
numOfTables
++
;
tsSdbMgmt
.
tableList
[
pTable
->
id
]
=
pTable
;
return
pTable
;
return
taosAddRef
(
tsSdbRid
,
pTable
);
}
void
sdbCloseTable
(
int64_t
rid
)
{
taosRemoveRef
(
tsSdbRid
,
rid
);
}
void
*
sdbGetTableByRid
(
int64_t
rid
)
{
void
*
handle
=
taosAcquireRef
(
tsSdbRid
,
rid
);
taosReleaseRef
(
tsSdbRid
,
rid
);
return
handle
;
}
void
sdbCloseTable
(
void
*
handle
)
{
static
void
sdbCloseTableObj
(
void
*
handle
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
handle
;
if
(
pTable
==
NULL
)
return
;
...
...
src/mnode/src/mnodeShow.c
浏览文件 @
b897d803
...
...
@@ -52,7 +52,6 @@ static bool mnodeCheckShowFinished(SShowObj *pShow);
static
void
*
mnodePutShowObj
(
SShowObj
*
pShow
);
static
void
mnodeReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
extern
void
*
tsMnodeTmr
;
static
void
*
tsMnodeShowCache
=
NULL
;
static
int32_t
tsShowObjIndex
=
0
;
static
SShowMetaFp
tsMnodeShowMetaFp
[
TSDB_MGMT_TABLE_MAX
]
=
{
0
};
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
b897d803
...
...
@@ -49,7 +49,9 @@
#define CREATE_CTABLE_RETRY_TIMES 10
#define CREATE_CTABLE_RETRY_SEC 14
int64_t
tsCTableRid
=
-
1
;
static
void
*
tsChildTableSdb
;
int64_t
tsSTableRid
=
-
1
;
static
void
*
tsSuperTableSdb
;
static
int32_t
tsChildTableUpdateSize
;
static
int32_t
tsSuperTableUpdateSize
;
...
...
@@ -350,7 +352,7 @@ static int32_t mnodeInitChildTables() {
SCTableObj
tObj
;
tsChildTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
SSdbTableDesc
tableD
esc
=
{
SSdbTableDesc
d
esc
=
{
.
id
=
SDB_TABLE_CTABLE
,
.
name
=
"ctables"
,
.
hashSessions
=
TSDB_DEFAULT_CTABLES_HASH_SIZE
,
...
...
@@ -366,7 +368,8 @@ static int32_t mnodeInitChildTables() {
.
fpRestored
=
mnodeChildTableActionRestored
};
tsChildTableSdb
=
sdbOpenTable
(
&
tableDesc
);
tsCTableRid
=
sdbOpenTable
(
&
desc
);
tsChildTableSdb
=
sdbGetTableByRid
(
tsCTableRid
);
if
(
tsChildTableSdb
==
NULL
)
{
mError
(
"failed to init child table data"
);
return
-
1
;
...
...
@@ -377,7 +380,7 @@ static int32_t mnodeInitChildTables() {
}
static
void
mnodeCleanupChildTables
()
{
sdbCloseTable
(
tsC
hildTableSdb
);
sdbCloseTable
(
tsC
TableRid
);
tsChildTableSdb
=
NULL
;
}
...
...
@@ -543,7 +546,7 @@ static int32_t mnodeInitSuperTables() {
SSTableObj
tObj
;
tsSuperTableUpdateSize
=
(
int8_t
*
)
tObj
.
updateEnd
-
(
int8_t
*
)
&
tObj
.
info
.
type
;
SSdbTableDesc
tableD
esc
=
{
SSdbTableDesc
d
esc
=
{
.
id
=
SDB_TABLE_STABLE
,
.
name
=
"stables"
,
.
hashSessions
=
TSDB_DEFAULT_STABLES_HASH_SIZE
,
...
...
@@ -559,7 +562,8 @@ static int32_t mnodeInitSuperTables() {
.
fpRestored
=
mnodeSuperTableActionRestored
};
tsSuperTableSdb
=
sdbOpenTable
(
&
tableDesc
);
tsSTableRid
=
sdbOpenTable
(
&
desc
);
tsSuperTableSdb
=
sdbGetTableByRid
(
tsSTableRid
);
if
(
tsSuperTableSdb
==
NULL
)
{
mError
(
"failed to init stables data"
);
return
-
1
;
...
...
@@ -570,7 +574,7 @@ static int32_t mnodeInitSuperTables() {
}
static
void
mnodeCleanupSuperTables
()
{
sdbCloseTable
(
tsS
uperTableSdb
);
sdbCloseTable
(
tsS
TableRid
);
tsSuperTableSdb
=
NULL
;
}
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
b897d803
...
...
@@ -33,6 +33,7 @@
#include "mnodeWrite.h"
#include "mnodePeer.h"
int64_t
tsUserRid
=
-
1
;
static
void
*
tsUserSdb
=
NULL
;
static
int32_t
tsUserUpdateSize
=
0
;
static
int32_t
mnodeGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
...
...
@@ -165,7 +166,8 @@ int32_t mnodeInitUsers() {
.
fpRestored
=
mnodeUserActionRestored
};
tsUserSdb
=
sdbOpenTable
(
&
desc
);
tsUserRid
=
sdbOpenTable
(
&
desc
);
tsUserSdb
=
sdbGetTableByRid
(
tsUserRid
);
if
(
tsUserSdb
==
NULL
)
{
mError
(
"table:%s, failed to create hash"
,
desc
.
name
);
return
-
1
;
...
...
@@ -185,7 +187,7 @@ int32_t mnodeInitUsers() {
}
void
mnodeCleanupUsers
()
{
sdbCloseTable
(
tsUser
Sdb
);
sdbCloseTable
(
tsUser
Rid
);
tsUserSdb
=
NULL
;
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
b897d803
...
...
@@ -51,6 +51,7 @@ char* vgroupStatus[] = {
"updating"
};
int64_t
tsVgroupRid
=
-
1
;
static
void
*
tsVgroupSdb
=
NULL
;
static
int32_t
tsVgUpdateSize
=
0
;
...
...
@@ -222,7 +223,8 @@ int32_t mnodeInitVgroups() {
.
fpRestored
=
mnodeVgroupActionRestored
,
};
tsVgroupSdb
=
sdbOpenTable
(
&
desc
);
tsVgroupRid
=
sdbOpenTable
(
&
desc
);
tsVgroupSdb
=
sdbGetTableByRid
(
tsVgroupRid
);
if
(
tsVgroupSdb
==
NULL
)
{
mError
(
"failed to init vgroups data"
);
return
-
1
;
...
...
@@ -610,7 +612,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle) {
}
void
mnodeCleanupVgroups
()
{
sdbCloseTable
(
tsVgroup
Sdb
);
sdbCloseTable
(
tsVgroup
Rid
);
tsVgroupSdb
=
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录