Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
35f02cdb
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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,发现更多精彩内容 >>
未验证
提交
35f02cdb
编写于
4月 23, 2023
作者:
X
Xiaoyu Wang
提交者:
GitHub
4月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21013 from taosdata/FIX/TD-23768-main
fix: change tdbTbInsert to tdbTbUpsert for meta update in tdb
上级
072eb2e8
3c535162
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
39 addition
and
19 deletion
+39
-19
include/util/tutil.h
include/util/tutil.h
+2
-0
source/dnode/vnode/src/meta/metaSnapshot.c
source/dnode/vnode/src/meta/metaSnapshot.c
+4
-3
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+33
-16
未找到文件。
include/util/tutil.h
浏览文件 @
35f02cdb
...
...
@@ -106,6 +106,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
goto LABEL; \
}
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/src/meta/metaSnapshot.c
浏览文件 @
35f02cdb
...
...
@@ -187,23 +187,24 @@ _err:
int32_t
metaSnapWrite
(
SMetaSnapWriter
*
pWriter
,
uint8_t
*
pData
,
uint32_t
nData
)
{
int32_t
code
=
0
;
int32_t
line
=
0
;
SMeta
*
pMeta
=
pWriter
->
pMeta
;
SMetaEntry
metaEntry
=
{
0
};
SDecoder
*
pDecoder
=
&
(
SDecoder
){
0
};
tDecoderInit
(
pDecoder
,
pData
+
sizeof
(
SSnapDataHdr
),
nData
-
sizeof
(
SSnapDataHdr
));
code
=
metaDecodeEntry
(
pDecoder
,
&
metaEntry
);
if
(
code
)
goto
_err
;
VND_CHECK_CODE
(
code
,
line
,
_err
)
;
code
=
metaHandleEntry
(
pMeta
,
&
metaEntry
);
if
(
code
)
goto
_err
;
VND_CHECK_CODE
(
code
,
line
,
_err
)
;
tDecoderClear
(
pDecoder
);
return
code
;
_err:
tDecoderClear
(
pDecoder
);
metaError
(
"vgId:%d, vnode snapshot meta write failed since %s
"
,
TD_VID
(
pMeta
->
pVnode
),
tstrerror
(
code
)
);
metaError
(
"vgId:%d, vnode snapshot meta write failed since %s
at line:%d"
,
TD_VID
(
pMeta
->
pVnode
),
terrstr
(),
line
);
return
code
;
}
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
35f02cdb
...
...
@@ -1029,7 +1029,7 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) {
metaTrace
(
"vgId:%d, start to save version:%"
PRId64
" uid:%"
PRId64
" ctime:%"
PRId64
,
TD_VID
(
pMeta
->
pVnode
),
pME
->
version
,
pME
->
uid
,
ctimeKey
.
ctime
);
return
tdbTb
In
sert
(
pMeta
->
pCtimeIdx
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pCtimeIdx
,
&
ctimeKey
,
sizeof
(
ctimeKey
),
NULL
,
0
,
pMeta
->
txn
);
}
int
metaDeleteCtimeIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
...
...
@@ -1044,7 +1044,7 @@ int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) {
if
(
metaBuildNColIdxKey
(
&
ncolKey
,
pME
)
<
0
)
{
return
0
;
}
return
tdbTb
In
sert
(
pMeta
->
pNcolIdx
,
&
ncolKey
,
sizeof
(
ncolKey
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pNcolIdx
,
&
ncolKey
,
sizeof
(
ncolKey
),
NULL
,
0
,
pMeta
->
txn
);
}
int
metaDeleteNcolIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
...
...
@@ -1878,24 +1878,24 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) {
}
static
int
metaUpdateSuidIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbTb
In
sert
(
pMeta
->
pSuidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pSuidIdx
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
NULL
,
0
,
pMeta
->
txn
);
}
static
int
metaUpdateNameIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
return
tdbTb
In
sert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pNameIdx
,
pME
->
name
,
strlen
(
pME
->
name
)
+
1
,
&
pME
->
uid
,
sizeof
(
tb_uid_t
),
pMeta
->
txn
);
}
static
int
metaUpdateTtlIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
STtlIdxKey
ttlKey
=
{
0
};
metaBuildTtlIdxKey
(
&
ttlKey
,
pME
);
if
(
ttlKey
.
dtime
==
0
)
return
0
;
return
tdbTb
In
sert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
pMeta
->
txn
);
return
tdbTb
Up
sert
(
pMeta
->
pTtlIdx
,
&
ttlKey
,
sizeof
(
ttlKey
),
NULL
,
0
,
pMeta
->
txn
);
}
static
int
metaUpdateCtbIdx
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
SCtbIdxKey
ctbIdxKey
=
{.
suid
=
pME
->
ctbEntry
.
suid
,
.
uid
=
pME
->
uid
};
return
tdbTb
In
sert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
pME
->
ctbEntry
.
pTags
,
return
tdbTb
Up
sert
(
pMeta
->
pCtbIdx
,
&
ctbIdxKey
,
sizeof
(
ctbIdxKey
),
pME
->
ctbEntry
.
pTags
,
((
STag
*
)(
pME
->
ctbEntry
.
pTags
))
->
len
,
pMeta
->
txn
);
}
...
...
@@ -2065,49 +2065,66 @@ _exit:
}
int
metaHandleEntry
(
SMeta
*
pMeta
,
const
SMetaEntry
*
pME
)
{
int32_t
code
=
0
;
int32_t
line
=
0
;
metaWLock
(
pMeta
);
// save to table.db
if
(
metaSaveToTbDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaSaveToTbDb
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
// update uid.idx
if
(
metaUpdateUidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateUidIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
// update name.idx
if
(
metaUpdateNameIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateNameIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
if
(
pME
->
type
==
TSDB_CHILD_TABLE
)
{
// update ctb.idx
if
(
metaUpdateCtbIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateCtbIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
// update tag.idx
if
(
metaUpdateTagIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateTagIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
else
{
// update schema.db
if
(
metaSaveToSkmDb
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaSaveToSkmDb
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
if
(
pME
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateSuidIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateSuidIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
}
if
(
metaUpdateCtimeIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateCtimeIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
if
(
pME
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
metaUpdateNcolIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateNcolIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
if
(
pME
->
type
!=
TSDB_SUPER_TABLE
)
{
if
(
metaUpdateTtlIdx
(
pMeta
,
pME
)
<
0
)
goto
_err
;
code
=
metaUpdateTtlIdx
(
pMeta
,
pME
);
VND_CHECK_CODE
(
code
,
line
,
_err
);
}
metaULock
(
pMeta
);
metaDebug
(
"vgId:%d, handle meta entry, ver:%"
PRId64
", uid:%"
PRId64
", name:%s"
,
TD_VID
(
pMeta
->
pVnode
),
pME
->
version
,
pME
->
uid
,
pME
->
name
);
return
0
;
_err:
metaULock
(
pMeta
);
metaError
(
"vgId:%d, failed to handle meta entry since %s at line:%d, ver:%"
PRId64
", uid:%"
PRId64
", name:%s"
,
TD_VID
(
pMeta
->
pVnode
),
terrstr
(),
line
,
pME
->
version
,
pME
->
uid
,
pME
->
name
);
return
-
1
;
}
// refactor later
void
*
metaGetIdx
(
SMeta
*
pMeta
)
{
return
pMeta
->
pTagIdx
;
}
void
*
metaGetIvtIdx
(
SMeta
*
pMeta
)
{
return
pMeta
->
pTagIvtIdx
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录