Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5fdaceb8
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
5fdaceb8
编写于
4月 29, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: adjust lock in sdb
上级
fe7f246c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
26 deletion
+16
-26
source/dnode/mnode/sdb/src/sdbHash.c
source/dnode/mnode/sdb/src/sdbHash.c
+16
-26
未找到文件。
source/dnode/mnode/sdb/src/sdbHash.c
浏览文件 @
5fdaceb8
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "sdbInt.h"
static
void
sdbCheck
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
);
static
void
sdbCheck
Row
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
);
const
char
*
sdbTableName
(
ESdbType
type
)
{
switch
(
type
)
{
...
...
@@ -65,7 +65,7 @@ const char *sdbTableName(ESdbType type) {
}
}
static
const
char
*
sdbStatus
Str
(
ESdbStatus
status
)
{
static
const
char
*
sdbStatus
Name
(
ESdbStatus
status
)
{
switch
(
status
)
{
case
SDB_STATUS_CREATING
:
return
"creating"
;
...
...
@@ -89,13 +89,13 @@ void sdbPrintOper(SSdb *pSdb, SSdbRow *pRow, const char *oper) {
if
(
keyType
==
SDB_KEY_BINARY
)
{
mTrace
(
"%s:%s, ref:%d oper:%s row:%p status:%s"
,
sdbTableName
(
pRow
->
type
),
(
char
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
,
pRow
->
pObj
,
sdbStatus
Str
(
pRow
->
status
));
pRow
->
pObj
,
sdbStatus
Name
(
pRow
->
status
));
}
else
if
(
keyType
==
SDB_KEY_INT32
)
{
mTrace
(
"%s:%d, ref:%d oper:%s row:%p status:%s"
,
sdbTableName
(
pRow
->
type
),
*
(
int32_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
,
pRow
->
pObj
,
sdbStatus
Str
(
pRow
->
status
));
oper
,
pRow
->
pObj
,
sdbStatus
Name
(
pRow
->
status
));
}
else
if
(
keyType
==
SDB_KEY_INT64
)
{
mTrace
(
"%s:%"
PRId64
", ref:%d oper:%s row:%p status:%s"
,
sdbTableName
(
pRow
->
type
),
*
(
int64_t
*
)
pRow
->
pObj
,
pRow
->
refCount
,
oper
,
pRow
->
pObj
,
sdbStatus
Str
(
pRow
->
status
));
pRow
->
refCount
,
oper
,
pRow
->
pObj
,
sdbStatus
Name
(
pRow
->
status
));
}
else
{
}
}
...
...
@@ -116,7 +116,7 @@ static SHashObj *sdbGetHash(SSdb *pSdb, int32_t type) {
}
static
int32_t
sdbGetkeySize
(
SSdb
*
pSdb
,
ESdbType
type
,
const
void
*
pKey
)
{
int32_t
keySize
;
int32_t
keySize
=
0
;
EKeyType
keyType
=
pSdb
->
keyTypes
[
type
];
if
(
keyType
==
SDB_KEY_INT32
)
{
...
...
@@ -149,7 +149,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
if
(
taosHashPut
(
hash
,
pRow
->
pObj
,
keySize
,
&
pRow
,
sizeof
(
void
*
))
!=
0
)
{
taosWUnLockLatch
(
pLock
);
sdbFreeRow
(
pSdb
,
pRow
,
false
);
terrno
=
TSDB_CODE_
SDB_OBJ_ALREADY_THERE
;
terrno
=
TSDB_CODE_
OUT_OF_MEMORY
;
return
terrno
;
}
...
...
@@ -183,18 +183,18 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
static
int32_t
sdbUpdateRow
(
SSdb
*
pSdb
,
SHashObj
*
hash
,
SSdbRaw
*
pRaw
,
SSdbRow
*
pNewRow
,
int32_t
keySize
)
{
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pNewRow
->
type
];
taos
R
LockLatch
(
pLock
);
taos
W
LockLatch
(
pLock
);
SSdbRow
**
ppOldRow
=
taosHashGet
(
hash
,
pNewRow
->
pObj
,
keySize
);
if
(
ppOldRow
==
NULL
||
*
ppOldRow
==
NULL
)
{
taos
R
UnLockLatch
(
pLock
);
taos
W
UnLockLatch
(
pLock
);
return
sdbInsertRow
(
pSdb
,
hash
,
pRaw
,
pNewRow
,
keySize
);
}
SSdbRow
*
pOldRow
=
*
ppOldRow
;
pOldRow
->
status
=
pRaw
->
status
;
sdbPrintOper
(
pSdb
,
pOldRow
,
"update"
);
taos
R
UnLockLatch
(
pLock
);
taos
W
UnLockLatch
(
pLock
);
int32_t
code
=
0
;
SdbUpdateFp
updateFp
=
pSdb
->
updateFps
[
pNewRow
->
type
];
...
...
@@ -230,7 +230,7 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
pSdb
->
tableVer
[
pOldRow
->
type
]
++
;
sdbFreeRow
(
pSdb
,
pRow
,
false
);
sdbCheck
(
pSdb
,
pOldRow
);
sdbCheck
Row
(
pSdb
,
pOldRow
);
return
0
;
}
...
...
@@ -314,9 +314,9 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) {
return
pRet
;
}
static
void
sdbCheck
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
)
{
static
void
sdbCheck
Row
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
)
{
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
taos
R
LockLatch
(
pLock
);
taos
W
LockLatch
(
pLock
);
int32_t
ref
=
atomic_load_32
(
&
pRow
->
refCount
);
sdbPrintOper
(
pSdb
,
pRow
,
"check"
);
...
...
@@ -324,7 +324,7 @@ static void sdbCheck(SSdb *pSdb, SSdbRow *pRow) {
sdbFreeRow
(
pSdb
,
pRow
,
true
);
}
taos
R
UnLockLatch
(
pLock
);
taos
W
UnLockLatch
(
pLock
);
}
void
sdbRelease
(
SSdb
*
pSdb
,
void
*
pObj
)
{
...
...
@@ -334,7 +334,7 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
if
(
pRow
->
type
>=
SDB_MAX
)
return
;
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
pRow
->
type
];
taos
R
LockLatch
(
pLock
);
taos
W
LockLatch
(
pLock
);
int32_t
ref
=
atomic_sub_fetch_32
(
&
pRow
->
refCount
,
1
);
sdbPrintOper
(
pSdb
,
pRow
,
"release"
);
...
...
@@ -342,7 +342,7 @@ void sdbRelease(SSdb *pSdb, void *pObj) {
sdbFreeRow
(
pSdb
,
pRow
,
true
);
}
taos
R
UnLockLatch
(
pLock
);
taos
W
UnLockLatch
(
pLock
);
}
void
*
sdbFetch
(
SSdb
*
pSdb
,
ESdbType
type
,
void
*
pIter
,
void
**
ppObj
)
{
...
...
@@ -354,16 +354,6 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) {
SRWLatch
*
pLock
=
&
pSdb
->
locks
[
type
];
taosRLockLatch
(
pLock
);
#if 0
if (pIter != NULL) {
SSdbRow *pLastRow = *(SSdbRow **)pIter;
int32_t ref = atomic_load_32(&pLastRow->refCount);
if (ref <= 0 && pLastRow->status == SDB_STATUS_DROPPED) {
sdbFreeRow(pSdb, pLastRow);
}
}
#endif
SSdbRow
**
ppRow
=
taosHashIterate
(
hash
,
pIter
);
while
(
ppRow
!=
NULL
)
{
SSdbRow
*
pRow
=
*
ppRow
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录