Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eb6f21bd
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
eb6f21bd
编写于
4月 03, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-93] add ref to sdb
上级
07fe4def
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
27 addition
and
18 deletion
+27
-18
src/inc/mnode.h
src/inc/mnode.h
+8
-0
src/mnode/inc/mgmtSdb.h
src/mnode/inc/mgmtSdb.h
+1
-0
src/mnode/src/mgmtAcct.c
src/mnode/src/mgmtAcct.c
+4
-4
src/mnode/src/mgmtDb.c
src/mnode/src/mgmtDb.c
+1
-0
src/mnode/src/mgmtSdb.c
src/mnode/src/mgmtSdb.c
+9
-14
src/mnode/src/mgmtTable.c
src/mnode/src/mgmtTable.c
+2
-0
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+1
-0
src/mnode/src/mgmtVgroup.c
src/mnode/src/mgmtVgroup.c
+1
-0
未找到文件。
src/inc/mnode.h
浏览文件 @
eb6f21bd
...
...
@@ -59,6 +59,7 @@ typedef struct {
char
mnodeName
[
TSDB_DNODE_NAME_LEN
+
1
];
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int
syncFd
;
void
*
hbTimer
;
void
*
pSync
;
...
...
@@ -84,6 +85,7 @@ typedef struct {
char
dnodeName
[
TSDB_DNODE_NAME_LEN
+
1
];
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SVnodeLoad
vload
[
TSDB_MAX_VNODES
];
int32_t
status
;
uint32_t
lastReboot
;
// time stamp for last reboot
...
...
@@ -115,6 +117,7 @@ typedef struct SSuperTableObj {
int32_t
numOfTags
;
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
int32_t
numOfTables
;
int16_t
nextColId
;
SSchema
*
schema
;
...
...
@@ -133,6 +136,7 @@ typedef struct {
int8_t
reserved
[
1
];
int8_t
updateEnd
[
1
];
int16_t
nextColId
;
//used by normal table
int32_t
refCount
;
char
*
sql
;
//used by normal table
SSchema
*
schema
;
//used by normal table
SSuperTableObj
*
superTable
;
...
...
@@ -149,6 +153,7 @@ typedef struct _vg_obj {
int8_t
lbStatus
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
_vg_obj
*
prev
,
*
next
;
struct
_db_obj
*
pDb
;
int32_t
numOfTables
;
...
...
@@ -163,6 +168,7 @@ typedef struct _db_obj {
SDbCfg
cfg
;
int8_t
reserved
[
15
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
_db_obj
*
prev
,
*
next
;
int32_t
numOfVgroups
;
int32_t
numOfTables
;
...
...
@@ -181,6 +187,7 @@ typedef struct _user_obj {
int8_t
writeAuth
;
int8_t
reserved
[
13
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
struct
_acctObj
*
pAcct
;
SQqueryList
*
pQList
;
// query list
SStreamList
*
pSList
;
// stream list
...
...
@@ -213,6 +220,7 @@ typedef struct _acctObj {
int8_t
dirty
;
int8_t
reserved
[
14
];
int8_t
updateEnd
[
1
];
int32_t
refCount
;
SAcctInfo
acctInfo
;
SDbObj
*
pHead
;
pthread_mutex_t
mutex
;
...
...
src/mnode/inc/mgmtSdb.h
浏览文件 @
eb6f21bd
...
...
@@ -44,6 +44,7 @@ typedef struct {
char
*
tableName
;
int32_t
hashSessions
;
int32_t
maxRowSize
;
int32_t
refCountPos
;
ESdbKeyType
keyType
;
int32_t
(
*
insertFp
)(
SSdbOperDesc
*
pOper
);
int32_t
(
*
deleteFp
)(
SSdbOperDesc
*
pOper
);
...
...
src/mnode/src/mgmtAcct.c
浏览文件 @
eb6f21bd
...
...
@@ -51,7 +51,7 @@ void acctAddDb(SAcctObj *pAcct, SDbObj *pDb) {
pAcct
->
acctInfo
.
numOfDbs
++
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
mgmtIncDbRef
(
pDb
);
acctIncRef
(
pAcct
);
}
void
acctRemoveDb
(
SAcctObj
*
pAcct
,
SDbObj
*
pDb
)
{
...
...
@@ -71,7 +71,7 @@ void acctRemoveDb(SAcctObj *pAcct, SDbObj *pDb) {
pAcct
->
acctInfo
.
numOfDbs
--
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
mgmtDecDbRef
(
pDb
);
acctDecRef
(
pAcct
);
}
void
acctAddUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
...
...
@@ -80,7 +80,7 @@ void acctAddUser(SAcctObj *pAcct, SUserObj *pUser) {
pUser
->
pAcct
=
pAcct
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
mgmtIncUserRef
(
pUser
);
acctIncRef
(
pAcct
);
}
void
acctRemoveUser
(
SAcctObj
*
pAcct
,
SUserObj
*
pUser
)
{
...
...
@@ -89,5 +89,5 @@ void acctRemoveUser(SAcctObj *pAcct, SUserObj *pUser) {
pUser
->
pAcct
=
NULL
;
pthread_mutex_unlock
(
&
pAcct
->
mutex
);
mgmtDecUserRef
(
pUser
);
acctDecRef
(
pAcct
);
}
\ No newline at end of file
src/mnode/src/mgmtDb.c
浏览文件 @
eb6f21bd
...
...
@@ -117,6 +117,7 @@ int32_t mgmtInitDbs() {
.
tableName
=
"dbs"
,
.
hashSessions
=
TSDB_MAX_DBS
,
.
maxRowSize
=
tsDbUpdateSize
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_TYPE_STRING
,
.
insertFp
=
mgmtDbActionInsert
,
.
deleteFp
=
mgmtDbActionDelete
,
...
...
src/mnode/src/mgmtSdb.c
浏览文件 @
eb6f21bd
...
...
@@ -47,6 +47,7 @@ typedef struct _SSdbTable {
int32_t
tableId
;
int32_t
hashSessions
;
int32_t
maxRowSize
;
int32_t
refCountPos
;
int32_t
autoIndex
;
int32_t
fd
;
int64_t
numOfRows
;
...
...
@@ -66,7 +67,6 @@ typedef struct {
int64_t
version
;
int64_t
offset
;
int32_t
rowSize
;
int32_t
refCount
;
void
*
row
;
}
SRowMeta
;
...
...
@@ -320,11 +320,6 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
}
}
else
{
if
(
rowHead
->
version
<
0
)
{
SSdbOperDesc
oper
=
{
.
table
=
pTable
,
.
pObj
=
pMetaRow
};
sdbDecRef
(
pTable
,
pMetaRow
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowHead
->
data
);
pTable
->
numOfRows
--
;
sdbTrace
(
"table:%s, version:%"
PRId64
" numOfRows:%d, read deleted record:%s"
,
...
...
@@ -340,13 +335,11 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
.
rowSize
=
rowHead
->
rowSize
,
.
pObj
=
pMetaRow
};
sdbDecRef
(
pTable
,
pMetaRow
);
(
*
sdbDeleteIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowHead
->
data
);
int32_t
code
=
(
*
pTable
->
decodeFp
)(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
rowMeta
.
row
=
oper
.
pObj
;
sdbIncRef
(
pTable
,
pMetaRow
);
(
*
sdbAddIndexFp
[
pTable
->
keyType
])(
pTable
->
iHandle
,
rowMeta
.
row
,
&
rowMeta
);
sdbTrace
(
"table:%s, version:%"
PRId64
" numOfRows:%d, read updated record:%s"
,
pTable
->
tableName
,
pTable
->
version
,
pTable
->
numOfRows
,
sdbGetkeyStr
(
pTable
,
rowHead
->
data
));
...
...
@@ -375,6 +368,7 @@ static int32_t sdbInitTableByFile(SSdbTable *pTable) {
.
version
=
pMeta
->
version
,
};
sdbIncRef
(
pTable
,
oper
.
pObj
);
int32_t
code
=
(
*
pTable
->
insertFp
)(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
sdbError
(
"table:%s, failed to insert record:%s"
,
pTable
->
tableName
,
sdbGetkeyStr
(
pTable
,
rowHead
->
data
));
...
...
@@ -398,6 +392,7 @@ void *sdbOpenTable(SSdbTableDesc *pDesc) {
pTable
->
keyType
=
pDesc
->
keyType
;
pTable
->
hashSessions
=
pDesc
->
hashSessions
;
pTable
->
maxRowSize
=
pDesc
->
maxRowSize
;
pTable
->
refCountPos
=
pDesc
->
refCountPos
;
pTable
->
insertFp
=
pDesc
->
insertFp
;
pTable
->
deleteFp
=
pDesc
->
deleteFp
;
pTable
->
updateFp
=
pDesc
->
updateFp
;
...
...
@@ -438,18 +433,18 @@ static SRowMeta *sdbGetRowMeta(void *handle, void *key) {
void
sdbIncRef
(
void
*
handle
,
void
*
pRow
)
{
if
(
pRow
)
{
SSdbTable
*
pTable
=
handle
;
SRowMeta
*
pMeta
=
(
pRow
-
4
);
atomic_add_fetch_32
(
&
pMeta
->
r
efCount
,
1
);
sdbTrace
(
"table:%s, add ref:%d to record:%s"
,
pTable
->
tableName
,
pMeta
->
r
efCount
,
sdbGetkeyStr
(
pTable
,
pRow
));
int32_t
*
pRefCount
=
(
int32_t
*
)(
pRow
+
pTable
->
refCountPos
);
atomic_add_fetch_32
(
pR
efCount
,
1
);
sdbTrace
(
"table:%s, add ref:%d to record:%s"
,
pTable
->
tableName
,
*
pR
efCount
,
sdbGetkeyStr
(
pTable
,
pRow
));
}
}
void
sdbDecRef
(
void
*
handle
,
void
*
pRow
)
{
if
(
pRow
)
{
SSdbTable
*
pTable
=
handle
;
SRowMeta
*
pMeta
=
(
pRow
-
4
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pMeta
->
r
efCount
,
1
);
sdbTrace
(
"table:%s, def ref:%d from record:%s"
,
pTable
->
tableName
,
pMeta
->
r
efCount
,
sdbGetkeyStr
(
pTable
,
pRow
));
int32_t
*
pRefCount
=
(
int32_t
*
)(
pRow
+
pTable
->
refCountPos
);
int32_t
refCount
=
atomic_sub_fetch_32
(
pR
efCount
,
1
);
sdbTrace
(
"table:%s, def ref:%d from record:%s"
,
pTable
->
tableName
,
*
pR
efCount
,
sdbGetkeyStr
(
pTable
,
pRow
));
if
(
refCount
<=
0
)
{
SSdbOperDesc
oper
=
{.
pObj
=
pRow
};
(
*
pTable
->
destroyFp
)(
&
oper
);
...
...
src/mnode/src/mgmtTable.c
浏览文件 @
eb6f21bd
...
...
@@ -236,6 +236,7 @@ static int32_t mgmtInitChildTables() {
.
tableName
=
"ctables"
,
.
hashSessions
=
tsMaxTables
,
.
maxRowSize
=
sizeof
(
SChildTableObj
)
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_TYPE_STRING
,
.
insertFp
=
mgmtChildTableActionInsert
,
.
deleteFp
=
mgmtChildTableActionDelete
,
...
...
@@ -411,6 +412,7 @@ static int32_t mgmtInitSuperTables() {
.
tableName
=
"stables"
,
.
hashSessions
=
TSDB_MAX_SUPER_TABLES
,
.
maxRowSize
=
tsSuperTableUpdateSize
+
sizeof
(
SSchema
)
*
TSDB_MAX_COLUMNS
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_TYPE_STRING
,
.
insertFp
=
mgmtSuperTableActionInsert
,
.
deleteFp
=
mgmtSuperTableActionDelete
,
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
eb6f21bd
...
...
@@ -99,6 +99,7 @@ int32_t mgmtInitUsers() {
.
tableName
=
"users"
,
.
hashSessions
=
TSDB_MAX_USERS
,
.
maxRowSize
=
tsUserUpdateSize
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_TYPE_STRING
,
.
insertFp
=
mgmtUserActionInsert
,
.
deleteFp
=
mgmtUserActionDelete
,
...
...
src/mnode/src/mgmtVgroup.c
浏览文件 @
eb6f21bd
...
...
@@ -149,6 +149,7 @@ int32_t mgmtInitVgroups() {
.
tableName
=
"vgroups"
,
.
hashSessions
=
TSDB_MAX_VGROUPS
,
.
maxRowSize
=
tsVgUpdateSize
,
.
refCountPos
=
(
int8_t
*
)(
&
tObj
.
refCount
)
-
(
int8_t
*
)
&
tObj
,
.
keyType
=
SDB_KEY_TYPE_AUTO
,
.
insertFp
=
mgmtVgroupActionInsert
,
.
deleteFp
=
mgmtVgroupActionDelete
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录