Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fded16d1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
fded16d1
编写于
12月 30, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix memory leak while drop user
上级
1b9b49c9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
25 addition
and
54 deletion
+25
-54
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+14
-8
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+6
-4
source/dnode/mnode/sdb/src/sdbRow.c
source/dnode/mnode/sdb/src/sdbRow.c
+3
-0
tests/script/general/user/basic1.sim
tests/script/general/user/basic1.sim
+2
-42
未找到文件。
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
fded16d1
...
...
@@ -75,7 +75,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
if
(
pRaw
==
NULL
)
return
-
1
;
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
mDebug
(
"user:%s, will be created while deploy sdb
"
,
userObj
.
user
);
mDebug
(
"user:%s, will be created while deploy sdb
, raw:%p"
,
userObj
.
user
,
pRaw
);
return
sdbWrite
(
pMnode
->
pSdb
,
pRaw
);
}
...
...
@@ -107,6 +107,7 @@ static SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_USER_RESERVE_SIZE
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
);
mTrace
(
"user:%s, encode to raw:%p, row:%p"
,
pUser
->
user
,
pRaw
,
pUser
);
return
pRaw
;
}
...
...
@@ -133,11 +134,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT8
(
pRaw
,
pRow
,
dataPos
,
&
pUser
->
superUser
)
SDB_GET_RESERVE
(
pRaw
,
pRow
,
dataPos
,
TSDB_USER_RESERVE_SIZE
)
mTrace
(
"user:%s, decode from raw:%p, row:%p"
,
pUser
->
user
,
pRaw
,
pUser
);
return
pRow
;
}
static
int32_t
mndUserActionInsert
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
mTrace
(
"user:%s, perform insert action
"
,
pUser
->
u
ser
);
mTrace
(
"user:%s, perform insert action
, row:%p"
,
pUser
->
user
,
pU
ser
);
pUser
->
prohibitDbHash
=
taosHashInit
(
8
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
pUser
->
prohibitDbHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -158,7 +160,7 @@ static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser) {
}
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
mTrace
(
"user:%s, perform delete action
"
,
pUser
->
u
ser
);
mTrace
(
"user:%s, perform delete action
, row:%p"
,
pUser
->
user
,
pU
ser
);
if
(
pUser
->
prohibitDbHash
)
{
taosHashCleanup
(
pUser
->
prohibitDbHash
);
pUser
->
prohibitDbHash
=
NULL
;
...
...
@@ -168,7 +170,7 @@ static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser) {
}
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOldUser
,
SUserObj
*
pNewUser
)
{
mTrace
(
"user:%s, perform update action
"
,
pOldUser
->
u
ser
);
mTrace
(
"user:%s, perform update action
, old_row:%p new_row:%p"
,
pOldUser
->
user
,
pOldUser
,
pNewU
ser
);
memcpy
(
pOldUser
->
pass
,
pNewUser
->
pass
,
TSDB_PASSWORD_LEN
);
pOldUser
->
updateTime
=
pNewUser
->
updateTime
;
return
0
;
...
...
@@ -242,7 +244,7 @@ static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg) {
SUserObj
*
pUser
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_USER
,
pCreate
->
user
);
if
(
pUser
!=
NULL
)
{
sdbRelease
(
pMnode
->
pSdb
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_USER_ALREADY_EXIST
;
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
return
-
1
;
...
...
@@ -256,7 +258,7 @@ static int32_t mndProcessCreateUserMsg(SMnodeMsg *pMsg) {
}
int32_t
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
pMsg
);
sdbRelease
(
pMnode
->
pSdb
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
if
(
code
!=
0
)
{
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
...
...
@@ -319,6 +321,7 @@ static int32_t mndProcessAlterUserMsg(SMnodeMsg *pMsg) {
SUserObj
*
pOperUser
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_USER
,
pMsg
->
user
);
if
(
pOperUser
==
NULL
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"user:%s, failed to alter since %s"
,
pAlter
->
user
,
terrstr
());
return
-
1
;
...
...
@@ -331,7 +334,8 @@ static int32_t mndProcessAlterUserMsg(SMnodeMsg *pMsg) {
newUser
.
updateTime
=
taosGetTimestampMs
();
int32_t
code
=
mndUpdateUser
(
pMnode
,
pUser
,
&
newUser
,
pMsg
);
sdbRelease
(
pMnode
->
pSdb
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
if
(
code
!=
0
)
{
mError
(
"user:%s, failed to alter since %s"
,
pAlter
->
user
,
terrstr
());
...
...
@@ -388,13 +392,15 @@ static int32_t mndProcessDropUserMsg(SMnodeMsg *pMsg) {
SUserObj
*
pOperUser
=
sdbAcquire
(
pMnode
->
pSdb
,
SDB_USER
,
pMsg
->
user
);
if
(
pOperUser
==
NULL
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"user:%s, failed to drop since %s"
,
pDrop
->
user
,
terrstr
());
return
-
1
;
}
int32_t
code
=
mndDropUser
(
pMnode
,
pMsg
,
pUser
);
sdbRelease
(
pMnode
->
pSdb
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
if
(
code
!=
0
)
{
mError
(
"user:%s, failed to drop since %s"
,
pDrop
->
user
,
terrstr
());
...
...
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
fded16d1
...
...
@@ -57,12 +57,14 @@ void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper) {
EKeyType
keyType
=
pSdb
->
keyTypes
[
pRow
->
type
];
if
(
keyType
==
SDB_KEY_BINARY
)
{
mTrace
(
"%s:%s, refCount:%d oper:%s"
,
sdbTableName
(
pRow
->
type
),
(
char
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
);
mTrace
(
"%s:%s, refCount:%d oper:%s row:%p"
,
sdbTableName
(
pRow
->
type
),
(
char
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
,
pRow
->
pObj
);
}
else
if
(
keyType
==
SDB_KEY_INT32
)
{
mTrace
(
"%s:%d, refCount:%d oper:%s"
,
sdbTableName
(
pRow
->
type
),
*
(
int32_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
);
mTrace
(
"%s:%d, refCount:%d oper:%s row:%p"
,
sdbTableName
(
pRow
->
type
),
*
(
int32_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
,
pRow
->
pObj
);
}
else
if
(
keyType
==
SDB_KEY_INT64
)
{
mTrace
(
"%s:%"
PRId64
", refCount:%d oper:%s
"
,
sdbTableName
(
pRow
->
type
),
*
(
int64_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
);
mTrace
(
"%s:%"
PRId64
", refCount:%d oper:%s
row:%p"
,
sdbTableName
(
pRow
->
type
),
*
(
int64_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
,
pRow
->
pObj
);
}
else
{
}
}
...
...
source/dnode/mnode/sdb/src/sdbRow.c
浏览文件 @
fded16d1
...
...
@@ -23,6 +23,7 @@ SSdbRow *sdbAllocRow(int32_t objSize) {
return
NULL
;
}
mTrace
(
"row:%p, is created, len:%d"
,
pRow
->
pObj
,
objSize
);
return
pRow
;
}
...
...
@@ -43,5 +44,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow) {
}
sdbPrintOper
(
pSdb
,
pRow
,
"freeRow"
);
mTrace
(
"row:%p, is freed"
,
pRow
->
pObj
);
tfree
(
pRow
);
}
tests/script/general/user/basic1.sim
浏览文件 @
fded16d1
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
system sh/exec.sh -n dnode1 -s start
-v
sql connect
print =============== show users
sql show users
if $rows != 1 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data22
print $data20 $data11 $data22
sql_error show accounts;
sql_error create account a pass "a"
sql_error drop account a
sql_error drop account root
print =============== create user1
sql create user user1 PASS 'user1'
...
...
@@ -30,23 +17,10 @@ print $data10 $data11 $data12
print $data20 $data11 $data22
print $data30 $data31 $data32
print =============== create user2
sql create user user2 PASS 'user2'
sql show users
if $rows != 3 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data12
print $data20 $data11 $data22
print $data30 $data31 $data32
print $data40 $data41 $data42
print =============== drop user1
sql drop user user1
sql show users
if $rows !=
2
then
if $rows !=
1
then
return -1
endi
...
...
@@ -57,18 +31,4 @@ print $data30 $data31 $data32
print =============== restart taosd
system sh/exec.sh -n dnode1 -s stop
sleep 1000
system sh/exec.sh -n dnode1 -s start
print =============== show users
sql show users
if $rows != 2 then
return -1
endi
print $data00 $data01 $data02
print $data10 $data11 $data22
print $data20 $data11 $data22
print $data30 $data31 $data32
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录