Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cf0228f8
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看板
提交
cf0228f8
编写于
5月 31, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
10e6e526
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
51 addition
and
45 deletion
+51
-45
source/dnode/vnode/src/tsdb/dev/inc/tsdbFS.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbFS.h
+7
-7
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
+32
-24
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
+12
-14
未找到文件。
source/dnode/vnode/src/tsdb/dev/inc/tsdbFS.h
浏览文件 @
cf0228f8
...
...
@@ -36,13 +36,13 @@ typedef enum {
int32_t
tsdbOpenFS
(
STsdb
*
pTsdb
,
STFileSystem
**
fs
,
int8_t
rollback
);
int32_t
tsdbCloseFS
(
STFileSystem
**
fs
);
// snapshot
int32_t
tsdbFSC
opySnapshot
(
STFileSystem
*
fs
,
TFileSetArray
*
fsetArr
);
int32_t
tsdbFS
ClearSnapshot
(
TFileSetArray
*
fsetArr
);
int32_t
tsdbFSC
reateCopySnapshot
(
STFileSystem
*
fs
,
TFileSetArray
*
*
fsetArr
);
int32_t
tsdbFS
DestroyCopySnapshot
(
TFileSetArray
*
*
fsetArr
);
// txn
int32_t
tsdbFSAllocEid
(
STFileSystem
*
pFS
,
int64_t
*
eid
);
int32_t
tsdbFSAllocEid
(
STFileSystem
*
fs
,
int64_t
*
eid
);
int32_t
tsdbFSEditBegin
(
STFileSystem
*
fs
,
const
TFileOpArray
*
opArray
,
EFEditT
etype
);
int32_t
tsdbFSEditCommit
(
STFileSystem
*
pFS
);
int32_t
tsdbFSEditAbort
(
STFileSystem
*
pFS
);
int32_t
tsdbFSEditCommit
(
STFileSystem
*
fs
);
int32_t
tsdbFSEditAbort
(
STFileSystem
*
fs
);
// other
int32_t
tsdbFSGetFSet
(
STFileSystem
*
fs
,
int32_t
fid
,
STFileSet
**
fset
);
...
...
@@ -53,8 +53,8 @@ struct STFileSystem {
int32_t
state
;
int64_t
neid
;
EFEditT
etype
;
TFileSetArray
cstate
;
TFileSetArray
nstate
;
TFileSetArray
fSetArr
[
1
]
;
TFileSetArray
fSetArrTmp
[
1
]
;
};
#ifdef __cplusplus
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
浏览文件 @
cf0228f8
...
...
@@ -45,16 +45,16 @@ static int32_t create_fs(STsdb *pTsdb, STFileSystem **fs) {
tsem_init
(
&
fs
[
0
]
->
canEdit
,
0
,
1
);
fs
[
0
]
->
state
=
TSDB_FS_STATE_NONE
;
fs
[
0
]
->
neid
=
0
;
TARRAY2_INIT
(
&
fs
[
0
]
->
cstate
);
TARRAY2_INIT
(
&
fs
[
0
]
->
nstate
);
TARRAY2_INIT
(
fs
[
0
]
->
fSetArr
);
TARRAY2_INIT
(
fs
[
0
]
->
fSetArrTmp
);
return
0
;
}
static
int32_t
destroy_fs
(
STFileSystem
**
fs
)
{
if
(
fs
[
0
]
==
NULL
)
return
0
;
TARRAY2_FREE
(
&
fs
[
0
]
->
cstate
);
TARRAY2_FREE
(
&
fs
[
0
]
->
nstate
);
TARRAY2_FREE
(
fs
[
0
]
->
fSetArr
);
TARRAY2_FREE
(
fs
[
0
]
->
fSetArrTmp
);
tsem_destroy
(
&
fs
[
0
]
->
canEdit
);
taosMemoryFree
(
fs
[
0
]);
fs
[
0
]
=
NULL
;
...
...
@@ -242,8 +242,8 @@ static bool is_same_file(const STFile *f1, const STFile f2) {
static
int32_t
apply_commit
(
STFileSystem
*
fs
)
{
int32_t
code
=
0
;
TFileSetArray
*
fsetArray1
=
&
fs
->
cstate
;
TFileSetArray
*
fsetArray2
=
&
fs
->
nstate
;
TFileSetArray
*
fsetArray1
=
fs
->
fSetArr
;
TFileSetArray
*
fsetArray2
=
fs
->
fSetArrTmp
;
int32_t
i1
=
0
,
i2
=
0
;
while
(
i1
<
TARRAY2_SIZE
(
fsetArray1
)
||
i2
<
TARRAY2_SIZE
(
fsetArray2
))
{
...
...
@@ -357,7 +357,7 @@ static int32_t tsdbFSScanAndFix(STFileSystem *fs) {
// get max commit id
const
STFileSet
*
fset
;
TARRAY2_FOREACH
(
&
fs
->
cstate
,
fset
)
{
fs
->
neid
=
TMAX
(
fs
->
neid
,
tsdbTFileSetMaxCid
(
fset
));
}
TARRAY2_FOREACH
(
fs
->
fSetArr
,
fset
)
{
fs
->
neid
=
TMAX
(
fs
->
neid
,
tsdbTFileSetMaxCid
(
fset
));
}
// TODO
return
0
;
...
...
@@ -371,8 +371,8 @@ static int32_t update_fs_if_needed(STFileSystem *pFS) {
static
int32_t
tsdbFSDupState
(
STFileSystem
*
fs
)
{
int32_t
code
;
const
TFileSetArray
*
src
=
&
fs
->
cstate
;
TFileSetArray
*
dst
=
&
fs
->
nstate
;
const
TFileSetArray
*
src
=
fs
->
fSetArr
;
TFileSetArray
*
dst
=
fs
->
fSetArrTmp
;
TARRAY2_CLEAR
(
dst
,
tsdbTFileSetClear
);
...
...
@@ -405,7 +405,7 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
current_fname
(
pTsdb
,
mCurrent
,
TSDB_FCURRENT_M
);
if
(
taosCheckExistFile
(
fCurrent
))
{
// current.json exists
code
=
load_fs
(
pTsdb
,
fCurrent
,
&
fs
->
cstate
);
code
=
load_fs
(
pTsdb
,
fCurrent
,
fs
->
fSetArr
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
taosCheckExistFile
(
cCurrent
))
{
...
...
@@ -416,7 +416,7 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
code
=
abort_edit
(
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
code
=
load_fs
(
pTsdb
,
cCurrent
,
&
fs
->
nstate
);
code
=
load_fs
(
pTsdb
,
cCurrent
,
fs
->
fSetArrTmp
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
commit_edit
(
fs
);
...
...
@@ -435,7 +435,7 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
code
=
tsdbFSScanAndFix
(
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
code
=
save_fs
(
&
fs
->
cstate
,
fCurrent
);
code
=
save_fs
(
fs
->
fSetArr
,
fCurrent
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
...
...
@@ -449,8 +449,8 @@ _exit:
}
static
int32_t
close_file_system
(
STFileSystem
*
fs
)
{
TARRAY2_CLEAR
(
&
fs
->
cstate
,
tsdbTFileSetClear
);
TARRAY2_CLEAR
(
&
fs
->
nstate
,
tsdbTFileSetClear
);
TARRAY2_CLEAR
(
fs
->
fSetArr
,
tsdbTFileSetClear
);
TARRAY2_CLEAR
(
fs
->
fSetArrTmp
,
tsdbTFileSetClear
);
// TODO
return
0
;
}
...
...
@@ -473,7 +473,7 @@ static int32_t fset_cmpr_fn(const struct STFileSet *pSet1, const struct STFileSe
static
int32_t
edit_fs
(
STFileSystem
*
fs
,
const
TFileOpArray
*
opArray
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
TFileSetArray
*
fsetArray
=
&
fs
->
nstate
;
TFileSetArray
*
fsetArray
=
fs
->
fSetArrTmp
;
STFileSet
*
fset
=
NULL
;
const
STFileOp
*
op
;
...
...
@@ -568,7 +568,7 @@ int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT e
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// save fs
code
=
save_fs
(
&
fs
->
nstate
,
current_t
);
code
=
save_fs
(
fs
->
fSetArrTmp
,
current_t
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
...
...
@@ -596,34 +596,42 @@ int32_t tsdbFSEditAbort(STFileSystem *fs) {
int32_t
tsdbFSGetFSet
(
STFileSystem
*
fs
,
int32_t
fid
,
STFileSet
**
fset
)
{
STFileSet
tfset
=
{.
fid
=
fid
};
STFileSet
*
pset
=
&
tfset
;
fset
[
0
]
=
TARRAY2_SEARCH_EX
(
&
fs
->
cstate
,
&
pset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
fset
[
0
]
=
TARRAY2_SEARCH_EX
(
fs
->
fSetArr
,
&
pset
,
tsdbTFileSetCmprFn
,
TD_EQ
);
return
0
;
}
int32_t
tsdbFSC
opySnapshot
(
STFileSystem
*
fs
,
TFileSetArray
*
fsetArr
)
{
int32_t
tsdbFSC
reateCopySnapshot
(
STFileSystem
*
fs
,
TFileSetArray
*
*
fsetArr
)
{
int32_t
code
=
0
;
STFileSet
*
fset
;
STFileSet
*
fset1
;
ASSERT
(
TARRAY2_SIZE
(
fsetArr
)
==
0
);
fsetArr
[
0
]
=
taosMemoryMalloc
(
sizeof
(
TFileSetArray
));
if
(
fsetArr
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
TARRAY2_INIT
(
fsetArr
[
0
]);
taosThreadRwlockRdlock
(
&
fs
->
tsdb
->
rwLock
);
TARRAY2_FOREACH
(
&
fs
->
cstate
,
fset
)
{
TARRAY2_FOREACH
(
fs
->
fSetArr
,
fset
)
{
code
=
tsdbTFileSetInitEx
(
fs
->
tsdb
,
fset
,
&
fset1
);
if
(
code
)
break
;
code
=
TARRAY2_APPEND
(
fsetArr
,
fset1
);
code
=
TARRAY2_APPEND
(
fsetArr
[
0
]
,
fset1
);
if
(
code
)
break
;
}
taosThreadRwlockUnlock
(
&
fs
->
tsdb
->
rwLock
);
if
(
code
)
{
TARRAY2_CLEAR
(
fsetArr
,
tsdbTFileSetClear
);
TARRAY2_CLEAR_FREE
(
fsetArr
[
0
],
tsdbTFileSetClear
);
taosMemoryFree
(
fsetArr
[
0
]);
fsetArr
[
0
]
=
NULL
;
}
return
code
;
}
int32_t
tsdbFSClearSnapshot
(
TFileSetArray
*
fsetArr
)
{
TARRAY2_CLEAR
(
fsetArr
,
tsdbTFileSetClear
);
int32_t
tsdbFSDestroyCopySnapshot
(
TFileSetArray
**
fsetArr
)
{
if
(
fsetArr
[
0
])
{
TARRAY2_CLEAR_FREE
(
fsetArr
[
0
],
tsdbTFileSetClear
);
fsetArr
[
0
]
=
NULL
;
}
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/dev/tsdbMerge.c
浏览文件 @
cf0228f8
...
...
@@ -16,16 +16,16 @@
#include "inc/tsdbMerge.h"
typedef
struct
{
STsdb
*
tsdb
;
TFileSetArray
fsetArr
[
1
]
;
int32_t
sttTrigger
;
int32_t
maxRow
;
int32_t
minRow
;
int32_t
szPage
;
int8_t
cmprAlg
;
int64_t
compactVersion
;
int64_t
cid
;
SSkmInfo
skmTb
[
1
];
STsdb
*
tsdb
;
TFileSetArray
*
fsetArr
;
int32_t
sttTrigger
;
int32_t
maxRow
;
int32_t
minRow
;
int32_t
szPage
;
int8_t
cmprAlg
;
int64_t
compactVersion
;
int64_t
cid
;
SSkmInfo
skmTb
[
1
];
// context
struct
{
...
...
@@ -549,18 +549,16 @@ int32_t tsdbMerge(STsdb *tsdb) {
SMerger
merger
[
1
]
=
{{
.
tsdb
=
tsdb
,
.
fsetArr
=
{
TARRAY2_INITIALIZER
},
.
sttTrigger
=
tsdb
->
pVnode
->
config
.
sttTrigger
,
}};
code
=
tsdbFSC
opySnapshot
(
tsdb
->
pFS
,
merger
->
fsetArr
);
code
=
tsdbFSC
reateCopySnapshot
(
tsdb
->
pFS
,
&
merger
->
fsetArr
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
tsdbDoMerge
(
merger
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
tsdbFSClearSnapshot
(
merger
->
fsetArr
);
TARRAY2_FREE
(
merger
->
fsetArr
);
tsdbFSDestroyCopySnapshot
(
&
merger
->
fsetArr
);
_exit:
if
(
code
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录