Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
61354eca
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
61354eca
编写于
5月 11, 2022
作者:
C
Cary Xu
提交者:
GitHub
5月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12331 from taosdata/feature/TD-14481-3.0
fix: commit table in mem and file
上级
afe77534
8cb2edb2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
79 addition
and
5 deletion
+79
-5
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+76
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+3
-3
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+0
-1
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
61354eca
...
...
@@ -70,6 +70,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid);
static
void
tsdbResetCommitFile
(
SCommitH
*
pCommith
);
static
int
tsdbSetAndOpenCommitFile
(
SCommitH
*
pCommith
,
SDFileSet
*
pSet
,
int
fid
);
static
int
tsdbCommitToTable
(
SCommitH
*
pCommith
,
int
tid
);
static
int
tsdbMoveBlkIdx
(
SCommitH
*
pCommith
,
SBlockIdx
*
pIdx
);
static
int
tsdbSetCommitTable
(
SCommitH
*
pCommith
,
STable
*
pTable
);
static
int
tsdbComparKeyBlock
(
const
void
*
arg1
,
const
void
*
arg2
);
static
int
tsdbWriteBlockInfo
(
SCommitH
*
pCommih
);
...
...
@@ -349,7 +350,7 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
if
(
tsdbSetAndOpenCommitFile
(
pCommith
,
pSet
,
fid
)
<
0
)
{
return
-
1
;
}
#if 0
// Loop to commit each table data
for (int tid = 0; tid < pCommith->niters; tid++) {
SCommitIter *pIter = pCommith->iters + tid;
...
...
@@ -363,6 +364,46 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
return -1;
}
}
#endif
// Loop to commit each table data in mem and file
int
mIter
=
0
,
fIter
=
0
;
int
nBlkIdx
=
taosArrayGetSize
(
pCommith
->
readh
.
aBlkIdx
);
while
(
true
)
{
SBlockIdx
*
pIdx
=
NULL
;
SCommitIter
*
pIter
=
NULL
;
if
(
mIter
<
pCommith
->
niters
)
{
pIter
=
pCommith
->
iters
+
mIter
;
if
(
fIter
<
nBlkIdx
)
{
pIdx
=
taosArrayGet
(
pCommith
->
readh
.
aBlkIdx
,
fIter
);
}
}
else
if
(
fIter
<
nBlkIdx
)
{
pIdx
=
taosArrayGet
(
pCommith
->
readh
.
aBlkIdx
,
fIter
);
}
else
{
break
;
}
if
(
pIter
&&
pIter
->
pTable
&&
(
!
pIdx
||
(
pIter
->
pTable
->
uid
<=
pIdx
->
uid
)))
{
if
(
tsdbCommitToTable
(
pCommith
,
mIter
)
<
0
)
{
tsdbCloseCommitFile
(
pCommith
,
true
);
// revert the file change
tsdbApplyDFileSetChange
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
),
pSet
);
return
-
1
;
}
if
(
pIdx
&&
(
pIter
->
pTable
->
uid
==
pIdx
->
uid
))
{
++
fIter
;
}
++
mIter
;
}
else
if
(
pIdx
)
{
if
(
tsdbMoveBlkIdx
(
pCommith
,
pIdx
)
<
0
)
{
tsdbCloseCommitFile
(
pCommith
,
true
);
// revert the file change
tsdbApplyDFileSetChange
(
TSDB_COMMIT_WRITE_FSET
(
pCommith
),
pSet
);
return
-
1
;
}
++
fIter
;
}
}
if
(
tsdbWriteBlockIdx
(
TSDB_COMMIT_HEAD_FILE
(
pCommith
),
pCommith
->
aBlkIdx
,
(
void
**
)(
&
(
TSDB_COMMIT_BUF
(
pCommith
))))
<
0
)
{
...
...
@@ -838,6 +879,40 @@ static int tsdbCommitToTable(SCommitH *pCommith, int tid) {
return
0
;
}
static
int
tsdbMoveBlkIdx
(
SCommitH
*
pCommith
,
SBlockIdx
*
pIdx
)
{
SReadH
*
pReadh
=
&
pCommith
->
readh
;
int
nBlocks
=
pIdx
->
numOfBlocks
;
int
bidx
=
0
;
tsdbResetCommitTable
(
pCommith
);
pReadh
->
pBlkIdx
=
pIdx
;
if
(
tsdbLoadBlockInfo
(
pReadh
,
NULL
)
<
0
)
{
return
-
1
;
}
while
(
bidx
<
nBlocks
)
{
if
(
tsdbMoveBlock
(
pCommith
,
bidx
)
<
0
)
{
tsdbError
(
"vgId:%d failed to move block into file %s since %s"
,
TSDB_COMMIT_REPO_ID
(
pCommith
),
TSDB_FILE_FULL_NAME
(
TSDB_COMMIT_HEAD_FILE
(
pCommith
)),
tstrerror
(
terrno
));
return
-
1
;
}
++
bidx
;
}
STable
table
=
{.
tid
=
pIdx
->
uid
,
.
uid
=
pIdx
->
uid
,
.
pSchema
=
NULL
};
TSDB_COMMIT_TABLE
(
pCommith
)
=
&
table
;
if
(
tsdbWriteBlockInfo
(
pCommith
)
<
0
)
{
tsdbError
(
"vgId:%d failed to write SBlockInfo part into file %s since %s"
,
TSDB_COMMIT_REPO_ID
(
pCommith
),
TSDB_FILE_FULL_NAME
(
TSDB_COMMIT_HEAD_FILE
(
pCommith
)),
tstrerror
(
terrno
));
return
-
1
;
}
return
0
;
}
static
int
tsdbSetCommitTable
(
SCommitH
*
pCommith
,
STable
*
pTable
)
{
STSchema
*
pSchema
=
tsdbGetTableSchemaImpl
(
pTable
,
false
,
false
,
-
1
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
61354eca
...
...
@@ -372,13 +372,13 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, STsdbReadHandle* pReadHandle,
}
if
(
level
==
TSDB_RETENTION_L0
)
{
tsdbDebug
(
"%p rsma level %d is selected to query
\n
"
,
pReadHandle
,
level
);
tsdbDebug
(
"%p rsma level %d is selected to query
"
,
pReadHandle
,
TSDB_RETENTION_L0
);
return
VND_RSMA0
(
pVnode
);
}
else
if
(
level
==
TSDB_RETENTION_L1
)
{
tsdbDebug
(
"%p rsma level %d is selected to query
\n
"
,
pReadHandle
,
level
);
tsdbDebug
(
"%p rsma level %d is selected to query
"
,
pReadHandle
,
TSDB_RETENTION_L1
);
return
VND_RSMA1
(
pVnode
);
}
else
{
tsdbDebug
(
"%p rsma level %d is selected to query
\n
"
,
pReadHandle
,
level
);
tsdbDebug
(
"%p rsma level %d is selected to query
"
,
pReadHandle
,
TSDB_RETENTION_L2
);
return
VND_RSMA2
(
pVnode
);
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
61354eca
...
...
@@ -1943,7 +1943,6 @@ static FORCE_INLINE int32_t tsdbUpdateTbUidListImpl(STsdb *pTsdb, tb_uid_t *suid
int32_t
tsdbUpdateTbUidList
(
STsdb
*
pTsdb
,
STbUidStore
*
pStore
)
{
if
(
!
pStore
||
(
taosArrayGetSize
(
pStore
->
tbUids
)
==
0
))
{
tsdbDebug
(
"vgId:%d no need to update tbUids since empty uidStore"
,
REPO_ID
(
pTsdb
));
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录