Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
38078033
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看板
提交
38078033
编写于
5月 19, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: change lockfree to rwlock
上级
c5d18b5a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
43 deletion
+43
-43
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
+4
-4
source/dnode/mgmt/mgmt_snode/inc/smInt.h
source/dnode/mgmt/mgmt_snode/inc/smInt.h
+0
-1
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
+1
-1
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
+12
-10
source/dnode/mgmt/node_mgmt/src/dmNodes.c
source/dnode/mgmt/node_mgmt/src/dmNodes.c
+2
-2
source/dnode/mgmt/node_util/inc/dmUtil.h
source/dnode/mgmt/node_util/inc/dmUtil.h
+12
-12
source/dnode/mgmt/node_util/src/dmEps.c
source/dnode/mgmt/node_util/src/dmEps.c
+12
-13
未找到文件。
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
浏览文件 @
38078033
...
...
@@ -19,11 +19,11 @@
static
void
dmUpdateDnodeCfg
(
SDnodeMgmt
*
pMgmt
,
SDnodeCfg
*
pCfg
)
{
if
(
pMgmt
->
pData
->
dnodeId
==
0
||
pMgmt
->
pData
->
clusterId
==
0
)
{
dInfo
(
"set dnodeId:%d clusterId:%"
PRId64
,
pCfg
->
dnodeId
,
pCfg
->
clusterId
);
taos
WLockLatch
(
&
pMgmt
->
pData
->
latch
);
taos
ThreadRwlockWrlock
(
&
pMgmt
->
pData
->
lock
);
pMgmt
->
pData
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
pData
->
clusterId
=
pCfg
->
clusterId
;
dmWriteEps
(
pMgmt
->
pData
);
taos
WUnLockLatch
(
&
pMgmt
->
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
pData
->
lock
);
}
}
...
...
@@ -50,7 +50,7 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
void
dmSendStatusReq
(
SDnodeMgmt
*
pMgmt
)
{
SStatusReq
req
=
{
0
};
taos
RLockLatch
(
&
pMgmt
->
pData
->
latch
);
taos
ThreadRwlockRdlock
(
&
pMgmt
->
pData
->
lock
);
req
.
sver
=
tsVersion
;
req
.
dnodeVer
=
pMgmt
->
pData
->
dnodeVer
;
req
.
dnodeId
=
pMgmt
->
pData
->
dnodeId
;
...
...
@@ -69,7 +69,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
memcpy
(
req
.
clusterCfg
.
timezone
,
tsTimezoneStr
,
TD_TIMEZONE_LEN
);
memcpy
(
req
.
clusterCfg
.
locale
,
tsLocale
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
taos
RUnLockLatch
(
&
pMgmt
->
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pMgmt
->
pData
->
lock
);
SMonVloadInfo
vinfo
=
{
0
};
(
*
pMgmt
->
getVnodeLoadsFp
)(
&
vinfo
);
...
...
source/dnode/mgmt/mgmt_snode/inc/smInt.h
浏览文件 @
38078033
...
...
@@ -30,7 +30,6 @@ typedef struct SSnodeMgmt {
SMsgCb
msgCb
;
const
char
*
path
;
const
char
*
name
;
SRWLatch
latch
;
int8_t
uniqueWorkerInUse
;
SArray
*
uniqueWorkers
;
// SArray<SMultiWorker*>
SSingleWorker
sharedWorker
;
...
...
source/dnode/mgmt/node_mgmt/inc/dmMgmt.h
浏览文件 @
38078033
...
...
@@ -70,7 +70,7 @@ typedef struct SMgmtWrapper {
const
char
*
name
;
char
*
path
;
int32_t
refCount
;
SRWLatch
latch
;
TdThreadRwlock
lock
;
EDndNodeType
ntype
;
bool
deployed
;
bool
required
;
...
...
source/dnode/mgmt/node_mgmt/src/dmMgmt.c
浏览文件 @
38078033
...
...
@@ -91,7 +91,7 @@ static int32_t dmInitVars(SDnode *pDnode, EDndNodeType rtype) {
return
-
1
;
}
taos
InitRWLatch
(
&
pData
->
latch
);
taos
ThreadRwlockInit
(
&
pData
->
lock
,
NULL
);
taosThreadMutexInit
(
&
pDnode
->
mutex
,
NULL
);
return
0
;
}
...
...
@@ -100,6 +100,7 @@ static void dmClearVars(SDnode *pDnode) {
for
(
EDndNodeType
ntype
=
DNODE
;
ntype
<
NODE_END
;
++
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
taosMemoryFreeClear
(
pWrapper
->
path
);
taosThreadRwlockDestroy
(
&
pWrapper
->
lock
);
}
if
(
pDnode
->
lockfile
!=
NULL
)
{
taosUnLockFile
(
pDnode
->
lockfile
);
...
...
@@ -108,7 +109,7 @@ static void dmClearVars(SDnode *pDnode) {
}
SDnodeData
*
pData
=
&
pDnode
->
data
;
taos
WLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockWrlock
(
&
pData
->
lock
);
if
(
pData
->
dnodeEps
!=
NULL
)
{
taosArrayDestroy
(
pData
->
dnodeEps
);
pData
->
dnodeEps
=
NULL
;
...
...
@@ -117,8 +118,9 @@ static void dmClearVars(SDnode *pDnode) {
taosHashCleanup
(
pData
->
dnodeHash
);
pData
->
dnodeHash
=
NULL
;
}
taos
WUnLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pData
->
lock
);
taosThreadRwlockDestroy
(
&
pData
->
lock
);
taosThreadMutexDestroy
(
&
pDnode
->
mutex
);
memset
(
&
pDnode
->
mutex
,
0
,
sizeof
(
pDnode
->
mutex
));
}
...
...
@@ -151,7 +153,7 @@ int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype) {
if
(
ntype
==
DNODE
)
{
pWrapper
->
proc
.
ptype
=
DND_PROC_SINGLE
;
}
taos
InitRWLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockInit
(
&
pWrapper
->
lock
,
NULL
);
snprintf
(
path
,
sizeof
(
path
),
"%s%s%s"
,
tsDataDir
,
TD_DIRSEP
,
pWrapper
->
name
);
pWrapper
->
path
=
strdup
(
path
);
...
...
@@ -223,7 +225,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
taos
RLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockRdlock
(
&
pWrapper
->
lock
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, ref:%d"
,
pWrapper
->
name
,
refCount
);
...
...
@@ -231,7 +233,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
taos
RUnLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockUnlock
(
&
pWrapper
->
lock
);
return
pRetWrapper
;
}
...
...
@@ -239,7 +241,7 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) {
int32_t
dmMarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
0
;
taos
RLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockRdlock
(
&
pWrapper
->
lock
);
if
(
pWrapper
->
deployed
||
(
InParentProc
(
pWrapper
)
&&
pWrapper
->
required
))
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, ref:%d"
,
pWrapper
->
name
,
refCount
);
...
...
@@ -247,7 +249,7 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
code
=
-
1
;
}
taos
RUnLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockUnlock
(
&
pWrapper
->
lock
);
return
code
;
}
...
...
@@ -255,9 +257,9 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) {
void
dmReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
taos
RLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockRdlock
(
&
pWrapper
->
lock
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taos
RUnLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockUnlock
(
&
pWrapper
->
lock
);
dTrace
(
"node:%s, is released, ref:%d"
,
pWrapper
->
name
,
refCount
);
}
...
...
source/dnode/mgmt/node_mgmt/src/dmNodes.c
浏览文件 @
38078033
...
...
@@ -186,12 +186,12 @@ void dmCloseNode(SMgmtWrapper *pWrapper) {
}
}
taos
WLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockWrlock
(
&
pWrapper
->
lock
);
if
(
pWrapper
->
pMgmt
!=
NULL
)
{
(
*
pWrapper
->
func
.
closeFp
)(
pWrapper
->
pMgmt
);
pWrapper
->
pMgmt
=
NULL
;
}
taos
WUnLockLatch
(
&
pWrapper
->
latch
);
taos
ThreadRwlockUnlock
(
&
pWrapper
->
lock
);
if
(
!
OnlyInSingleProc
(
pWrapper
))
{
dmCleanupProc
(
pWrapper
);
...
...
source/dnode/mgmt/node_util/inc/dmUtil.h
浏览文件 @
38078033
...
...
@@ -94,18 +94,18 @@ typedef void (*GetVnodeLoadsFp)();
typedef
void
(
*
GetMnodeLoadsFp
)();
typedef
struct
{
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
dnodeVer
;
int64_t
updateTime
;
int64_t
rebootTime
;
bool
dropped
;
bool
stopped
;
SEpSet
mnodeEps
;
SArray
*
dnodeEps
;
SHashObj
*
dnodeHash
;
SRWLatch
latch
;
SMsgCb
msgCb
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
dnodeVer
;
int64_t
updateTime
;
int64_t
rebootTime
;
bool
dropped
;
bool
stopped
;
SEpSet
mnodeEps
;
SArray
*
dnodeEps
;
SHashObj
*
dnodeHash
;
TdThreadRwlock
lock
;
SMsgCb
msgCb
;
}
SDnodeData
;
typedef
struct
{
...
...
source/dnode/mgmt/node_util/src/dmEps.c
浏览文件 @
38078033
...
...
@@ -21,7 +21,7 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep);
static
void
dmResetEps
(
SDnodeData
*
pData
,
SArray
*
dnodeEps
);
static
void
dmGetDnodeEp
(
SDnodeData
*
pData
,
int32_t
dnodeId
,
char
*
pEp
,
char
*
pFqdn
,
uint16_t
*
pPort
)
{
taos
RLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockRdlock
(
&
pData
->
lock
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pData
->
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
...
...
@@ -36,7 +36,7 @@ static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pF
}
}
taos
RUnLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pData
->
lock
);
}
int32_t
dmReadEps
(
SDnodeData
*
pData
)
{
...
...
@@ -232,7 +232,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
int32_t
numOfEps
=
taosArrayGetSize
(
eps
);
if
(
numOfEps
<=
0
)
return
;
taos
WLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockWrlock
(
&
pData
->
lock
);
int32_t
numOfEpsOld
=
(
int32_t
)
taosArrayGetSize
(
pData
->
dnodeEps
);
if
(
numOfEps
!=
numOfEpsOld
)
{
...
...
@@ -246,7 +246,7 @@ void dmUpdateEps(SDnodeData *pData, SArray *eps) {
}
}
taos
WUnLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pData
->
lock
);
}
static
void
dmResetEps
(
SDnodeData
*
pData
,
SArray
*
dnodeEps
)
{
...
...
@@ -292,7 +292,7 @@ static void dmPrintEps(SDnodeData *pData) {
static
bool
dmIsEpChanged
(
SDnodeData
*
pData
,
int32_t
dnodeId
,
const
char
*
ep
)
{
bool
changed
=
false
;
if
(
dnodeId
==
0
)
return
changed
;
taos
RLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockRdlock
(
&
pData
->
lock
);
SDnodeEp
*
pDnodeEp
=
taosHashGet
(
pData
->
dnodeHash
,
&
dnodeId
,
sizeof
(
int32_t
));
if
(
pDnodeEp
!=
NULL
)
{
...
...
@@ -304,24 +304,23 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) {
}
}
taos
RUnLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pData
->
lock
);
return
changed
;
}
void
dmGetMnodeEpSet
(
SDnodeData
*
pData
,
SEpSet
*
pEpSet
)
{
taos
RLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockRdlock
(
&
pData
->
lock
);
*
pEpSet
=
pData
->
mnodeEps
;
taos
RUnLockLatch
(
&
pData
->
latch
);
taos
ThreadRwlockUnlock
(
&
pData
->
lock
);
}
void
dmSetMnodeEpSet
(
SDnodeData
*
pData
,
SEpSet
*
pEpSet
)
{
dInfo
(
"mnode is changed, num:%d use:%d"
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
taosWLockLatch
(
&
pData
->
latch
);
taosThreadRwlockWrlock
(
&
pData
->
lock
);
pData
->
mnodeEps
=
*
pEpSet
;
taosThreadRwlockUnlock
(
&
pData
->
lock
);
dInfo
(
"mnode is changed, num:%d use:%d"
,
pEpSet
->
numOfEps
,
pEpSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
pEpSet
->
numOfEps
;
++
i
)
{
dInfo
(
"mnode index:%d %s:%u"
,
i
,
pEpSet
->
eps
[
i
].
fqdn
,
pEpSet
->
eps
[
i
].
port
);
}
taosWUnLockLatch
(
&
pData
->
latch
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录