Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f49f9604
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
f49f9604
编写于
6月 21, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'enh/tsdb_optimize' of github.com:taosdata/tdengine into enh/tsdb_optimize
上级
e76ae4ff
32a256bf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
134 addition
and
6 deletion
+134
-6
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+2
-2
source/dnode/vnode/src/tsdb/tsdbCommit2.c
source/dnode/vnode/src/tsdb/tsdbCommit2.c
+8
-0
source/dnode/vnode/src/tsdb/tsdbSttFileRW.h
source/dnode/vnode/src/tsdb/tsdbSttFileRW.h
+0
-1
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
+122
-3
source/dnode/vnode/src/tsdb/tsdbUtil2.h
source/dnode/vnode/src/tsdb/tsdbUtil2.h
+2
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
f49f9604
...
...
@@ -370,12 +370,12 @@ struct STsdb {
TdThreadRwlock
rwLock
;
SMemTable
*
mem
;
SMemTable
*
imem
;
STsdbFS
fs
;
STsdbFS
fs
;
// old
SLRUCache
*
lruCache
;
TdThreadMutex
lruMutex
;
SLRUCache
*
biCache
;
TdThreadMutex
biMutex
;
struct
STFileSystem
*
pFS
;
struct
STFileSystem
*
pFS
;
// new
SRocksCache
rCache
;
};
...
...
source/dnode/vnode/src/tsdb/tsdbCommit2.c
浏览文件 @
f49f9604
...
...
@@ -122,6 +122,14 @@ static int32_t tsdbCommitTSData(SCommitter2 *committer) {
committer
->
ctx
->
tbid
->
uid
=
row
->
uid
;
}
int64_t
ts
=
TSDBROW_TS
(
&
row
->
row
);
if
(
ts
>
committer
->
ctx
->
maxKey
)
{
committer
->
ctx
->
nextKey
=
TMIN
(
committer
->
ctx
->
nextKey
,
ts
);
code
=
tsdbIterMergerSkipTableData
(
committer
->
dataIterMerger
,
(
TABLEID
*
)
row
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
continue
;
}
code
=
tsdbFSetWriteRow
(
committer
->
writer
,
row
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/tsdb/tsdbSttFileRW.h
浏览文件 @
f49f9604
...
...
@@ -25,7 +25,6 @@ extern "C" {
typedef
TARRAY2
(
SSttBlk
)
TSttBlkArray
;
typedef
TARRAY2
(
SStatisBlk
)
TStatisBlkArray
;
typedef
TARRAY2
(
STombBlk
)
TTombBlkArray
;
// SSttFileReader ==========================================
typedef
struct
SSttFileReader
SSttFileReader
;
...
...
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
浏览文件 @
f49f9604
...
...
@@ -123,13 +123,130 @@ _exit:
return
code
;
}
static
int32_t
tsdbDumpTombDataToFSet
(
STsdb
*
tsdb
,
SDelFReader
*
reader
,
SArray
*
aDelIdx
,
STFileSet
*
fset
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
SArray
*
aDelData
=
NULL
;
int64_t
minKey
,
maxKey
;
STombBlock
tombBlock
[
1
]
=
{
0
};
TTombBlkArray
tombBlkArray
[
1
]
=
{
0
};
STsdbFD
*
fd
=
NULL
;
tsdbFidKeyRange
(
fset
->
fid
,
tsdb
->
keepCfg
.
days
,
tsdb
->
keepCfg
.
precision
,
&
minKey
,
&
maxKey
);
if
((
aDelData
=
taosArrayInit
(
0
,
sizeof
(
SDelData
)))
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
aDelIdx
);
++
i
)
{
SDelIdx
*
pDelIdx
=
taosArrayGet
(
aDelIdx
,
i
);
code
=
tsdbReadDelData
(
reader
,
pDelIdx
,
aDelData
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
for
(
int32_t
j
=
0
;
j
<
taosArrayGetSize
(
aDelData
);
++
j
)
{
SDelData
*
pDelData
=
taosArrayGet
(
aDelData
,
j
);
if
(
pDelData
->
sKey
>
maxKey
||
pDelData
->
eKey
<
minKey
)
{
continue
;
}
STombRecord
record
=
{
.
suid
=
pDelIdx
->
suid
,
.
uid
=
pDelIdx
->
uid
,
.
version
=
pDelData
->
version
,
.
skey
=
pDelData
->
sKey
,
.
ekey
=
pDelData
->
eKey
,
};
code
=
tTombBlockPut
(
tombBlock
,
&
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
TOMB_BLOCK_SIZE
(
tombBlock
)
>=
tsdb
->
pVnode
->
config
.
tsdbCfg
.
maxRows
)
{
if
(
fd
==
NULL
)
{
STFile
file
=
{
.
type
=
TSDB_FTYPE_TOMB
,
.
did
=
{
0
},
// TODO
.
fid
=
fset
->
fid
,
.
cid
=
0
,
// TODO
};
code
=
tsdbTFileObjInit
(
tsdb
,
&
file
,
&
fset
->
farr
[
TSDB_FTYPE_TOMB
]);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbOpenFile
(
fset
->
farr
[
TSDB_FTYPE_TOMB
]
->
fname
,
tsdb
->
pVnode
->
config
.
tsdbPageSize
,
TD_FILE_READ
|
TD_FILE_WRITE
|
TD_FILE_CREATE
|
TD_FILE_TRUNC
,
&
fd
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
uint8_t
hdr
[
TSDB_FHDR_SIZE
]
=
{
0
};
code
=
tsdbWriteFile
(
fd
,
0
,
hdr
,
TSDB_FHDR_SIZE
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
fset
->
farr
[
TSDB_FTYPE_TOMB
]
->
f
->
size
+=
sizeof
(
hdr
);
}
// TODO
tTombBlockClear
(
tombBlock
);
}
}
}
if
(
TOMB_BLOCK_SIZE
(
tombBlock
)
>
0
)
{
// TODO
tTombBlockClear
(
tombBlock
);
}
if
(
TARRAY2_SIZE
(
tombBlkArray
)
>
0
)
{
// TODO
}
if
(
fd
)
{
code
=
tsdbFsyncFile
(
fd
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tsdbCloseFile
(
&
fd
);
}
TARRAY2_DESTROY
(
tombBlkArray
,
NULL
);
tTombBlockDestroy
(
tombBlock
);
taosArrayDestroy
(
aDelData
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
tsdb
->
pVnode
),
lino
,
code
);
}
return
code
;
}
static
int32_t
tsdbUpgradeTombFile
(
STsdb
*
tsdb
,
SDelFile
*
pDelFile
,
TFileSetArray
*
fileSetArray
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
// TODO
SDelFReader
*
reader
=
NULL
;
SArray
*
aDelIdx
=
NULL
;
if
((
aDelIdx
=
taosArrayInit
(
0
,
sizeof
(
SDelIdx
)))
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbDelFReaderOpen
(
&
reader
,
pDelFile
,
tsdb
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbReadDelIdx
(
reader
,
aDelIdx
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
taosArrayGetSize
(
aDelIdx
)
>
0
)
{
STFileSet
*
fset
;
TARRAY2_FOREACH
(
fileSetArray
,
fset
)
{
code
=
tsdbDumpTombDataToFSet
(
tsdb
,
reader
,
aDelIdx
,
fset
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
}
tsdbDelFReaderClose
(
&
reader
);
taosArrayDestroy
(
aDelIdx
);
ASSERT
(
0
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
tsdb
->
pVnode
),
lino
,
code
);
...
...
@@ -166,9 +283,11 @@ static int32_t tsdbDoUpgradeFileSystem(STsdb *tsdb, int8_t rollback) {
char
fname
[
TSDB_FILENAME_LEN
];
current_fname
(
tsdb
,
fname
,
TSDB_FCURRENT
);
code
=
save_fs
(
fileSetArray
,
NULL
);
code
=
save_fs
(
fileSetArray
,
fname
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
TARRAY2_DESTROY
(
fileSetArray
,
tsdbTFileSetClear
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
tsdb
->
pVnode
),
lino
,
code
);
...
...
source/dnode/vnode/src/tsdb/tsdbUtil2.h
浏览文件 @
f49f9604
...
...
@@ -58,6 +58,8 @@ typedef struct {
int8_t
rsvd
[
7
];
}
STombBlk
;
typedef
TARRAY2
(
STombBlk
)
TTombBlkArray
;
#define TOMB_BLOCK_SIZE(db) TARRAY2_SIZE((db)->suid)
int32_t
tTombBlockInit
(
STombBlock
*
tombBlock
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录