Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5987f750
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看板
未验证
提交
5987f750
编写于
5月 11, 2022
作者:
H
Hongze Cheng
提交者:
GitHub
5月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12354 from taosdata/fix/hzcheng_3.0
fix: concurrent r/w meta
上级
31d0fa36
b15df1e9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
37 addition
and
7 deletion
+37
-7
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+5
-0
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+12
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+4
-0
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+14
-7
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+2
-0
未找到文件。
source/dnode/vnode/src/inc/meta.h
浏览文件 @
5987f750
...
...
@@ -37,6 +37,9 @@ typedef struct SMSmaCursor SMSmaCursor;
// clang-format on
// metaOpen ==================
int32_t
metaRLock
(
SMeta
*
pMeta
);
int32_t
metaWLock
(
SMeta
*
pMeta
);
int32_t
metaULock
(
SMeta
*
pMeta
);
// metaEntry ==================
int
metaEncodeEntry
(
SEncoder
*
pCoder
,
const
SMetaEntry
*
pME
);
...
...
@@ -57,6 +60,8 @@ int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
static
FORCE_INLINE
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
return
tGenIdPI64
();
}
struct
SMeta
{
TdThreadRwlock
lock
;
char
*
path
;
SVnode
*
pVnode
;
TENV
*
pEnv
;
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
5987f750
...
...
@@ -22,6 +22,9 @@ static int tagIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int kL
static
int
ttlIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int
uidIdxKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
);
static
int32_t
metaInitLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockInit
(
&
pMeta
->
lock
,
NULL
);
}
static
int32_t
metaDestroyLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockDestroy
(
&
pMeta
->
lock
);
}
int
metaOpen
(
SVnode
*
pVnode
,
SMeta
**
ppMeta
)
{
SMeta
*
pMeta
=
NULL
;
int
ret
;
...
...
@@ -36,6 +39,7 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
return
-
1
;
}
metaInitLock
(
pMeta
);
pMeta
->
path
=
(
char
*
)
&
pMeta
[
1
];
sprintf
(
pMeta
->
path
,
"%s%s%s%s%s"
,
tfsGetPrimaryPath
(
pVnode
->
pTfs
),
TD_DIRSEP
,
pVnode
->
path
,
TD_DIRSEP
,
VNODE_META_DIR
);
...
...
@@ -121,6 +125,7 @@ _err:
if
(
pMeta
->
pSkmDb
)
tdbDbClose
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdbDbClose
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pEnv
)
tdbEnvClose
(
pMeta
->
pEnv
);
metaDestroyLock
(
pMeta
);
taosMemoryFree
(
pMeta
);
return
-
1
;
}
...
...
@@ -136,12 +141,19 @@ int metaClose(SMeta *pMeta) {
if
(
pMeta
->
pSkmDb
)
tdbDbClose
(
pMeta
->
pSkmDb
);
if
(
pMeta
->
pTbDb
)
tdbDbClose
(
pMeta
->
pTbDb
);
if
(
pMeta
->
pEnv
)
tdbEnvClose
(
pMeta
->
pEnv
);
metaDestroyLock
(
pMeta
);
taosMemoryFree
(
pMeta
);
}
return
0
;
}
int32_t
metaRLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockRdlock
(
&
pMeta
->
lock
);
}
int32_t
metaWLock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockWrlock
(
&
pMeta
->
lock
);
}
int32_t
metaULock
(
SMeta
*
pMeta
)
{
return
taosThreadRwlockUnlock
(
&
pMeta
->
lock
);
}
static
int
tbDbKeyCmpr
(
const
void
*
pKey1
,
int
kLen1
,
const
void
*
pKey2
,
int
kLen2
)
{
STbDbKey
*
pTbDbKey1
=
(
STbDbKey
*
)
pKey1
;
STbDbKey
*
pTbDbKey2
=
(
STbDbKey
*
)
pKey2
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
5987f750
...
...
@@ -19,9 +19,13 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) {
memset
(
pReader
,
0
,
sizeof
(
*
pReader
));
pReader
->
flags
=
flags
;
pReader
->
pMeta
=
pMeta
;
metaRLock
(
pMeta
);
}
void
metaReaderClear
(
SMetaReader
*
pReader
)
{
if
(
pReader
->
pMeta
)
{
metaULock
(
pReader
->
pMeta
);
}
tDecoderClear
(
&
pReader
->
coder
);
tdbFree
(
pReader
->
pBuf
);
}
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
5987f750
...
...
@@ -439,29 +439,36 @@ _exit:
}
static
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
metaWLock
(
pMeta
);
// save to table.db
if
(
metaSaveToTbDb
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaSaveToTbDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
// update uid.idx
if
(
metaUpdateUidIdx
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaUpdateUidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
// update name.idx
if
(
metaUpdateNameIdx
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaUpdateNameIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
// update ctb.idx
if
(
metaUpdateCtbIdx
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaUpdateCtbIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
// update tag.idx
if
(
metaUpdateTagIdx
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaUpdateTagIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
}
else
{
// update schema.db
if
(
metaSaveToSkmDb
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaSaveToSkmDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
}
if
(
pME
->
type
!=
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateTtlIdx
(
pMeta
,
pME
)
<
0
)
return
-
1
;
if
(
metaUpdateTtlIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
}
metaULock
(
pMeta
);
return
0
;
_err:
metaULock
(
pMeta
);
return
-
1
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
5987f750
...
...
@@ -3870,6 +3870,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
metaReaderClear
(
&
mr
);
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
goto
_error
;
}
else
{
...
...
@@ -3880,6 +3881,7 @@ int32_t tsdbQuerySTableByTagCond(void* pMeta, uint64_t uid, TSKEY skey, const ch
tsdbError
(
"%p query normal tag not allowed, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
// basically, this error is caused by invalid sql issued by client
metaReaderClear
(
&
mr
);
goto
_error
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录