Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b75aca75
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看板
提交
b75aca75
编写于
5月 19, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
1c4abc62
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
19 deletion
+44
-19
source/dnode/vnode/src/tsdb/dev/inc/tsdbFS.h
source/dnode/vnode/src/tsdb/dev/inc/tsdbFS.h
+2
-2
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
+41
-16
未找到文件。
source/dnode/vnode/src/tsdb/dev/inc/tsdbFS.h
浏览文件 @
b75aca75
...
...
@@ -24,6 +24,7 @@ extern "C" {
/* Exposed Handle */
typedef
struct
STFileSystem
STFileSystem
;
typedef
TARRAY2
(
STFileOp
)
TFileOpArray
;
typedef
enum
{
TSDB_FEDIT_COMMIT
=
1
,
//
...
...
@@ -36,7 +37,7 @@ int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback);
int32_t
tsdbCloseFS
(
STFileSystem
**
fs
);
// txn
int32_t
tsdbFSAllocEid
(
STFileSystem
*
pFS
,
int64_t
*
eid
);
int32_t
tsdbFSEditBegin
(
STFileSystem
*
fs
,
int64_t
eid
,
const
SArray
*
aFileOp
,
EFEditT
etype
);
int32_t
tsdbFSEditBegin
(
STFileSystem
*
fs
,
const
SArray
*
aFileOp
,
EFEditT
etype
);
int32_t
tsdbFSEditCommit
(
STFileSystem
*
pFS
);
int32_t
tsdbFSEditAbort
(
STFileSystem
*
pFS
);
// other
...
...
@@ -49,7 +50,6 @@ struct STFileSystem {
int32_t
state
;
int64_t
neid
;
EFEditT
etype
;
int64_t
eid
;
TFileSetArray
cstate
;
TFileSetArray
nstate
;
};
...
...
source/dnode/vnode/src/tsdb/dev/tsdbCommit.c
浏览文件 @
b75aca75
...
...
@@ -363,7 +363,7 @@ static int32_t close_committer(SCommitter *pCommiter, int32_t eno) {
int32_t
vid
=
TD_VID
(
pCommiter
->
pTsdb
->
pVnode
);
if
(
eno
==
0
)
{
code
=
tsdbFSEditBegin
(
pCommiter
->
pTsdb
->
pFS
,
pCommiter
->
eid
,
pCommiter
->
aFileOp
,
TSDB_FEDIT_COMMIT
);
code
=
tsdbFSEditBegin
(
pCommiter
->
pTsdb
->
pFS
,
pCommiter
->
aFileOp
,
TSDB_FEDIT_COMMIT
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
// TODO
...
...
source/dnode/vnode/src/tsdb/dev/tsdbFS.c
浏览文件 @
b75aca75
...
...
@@ -190,7 +190,7 @@ static int32_t load_fs(const char *fname, TFileSetArray *arr) {
int32_t
code
=
0
;
int32_t
lino
=
0
;
TARRAY2_CLEAR
(
arr
,
NULL
);
TARRAY2_CLEAR
(
arr
,
tsdbTFileSetClear
);
// load json
cJSON
*
json
=
NULL
;
...
...
@@ -352,7 +352,7 @@ _exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
));
}
else
{
tsdbInfo
(
"vgId:%d %s success, e
id:%"
PRId64
" etype:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
fs
->
eid
,
fs
->
etype
);
tsdbInfo
(
"vgId:%d %s success, e
type:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
fs
->
etype
);
}
return
code
;
}
...
...
@@ -387,7 +387,7 @@ _exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed since %s"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
tstrerror
(
code
));
}
else
{
tsdbInfo
(
"vgId:%d %s success, e
id:%"
PRId64
" etype:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
fs
->
eid
,
fs
->
etype
);
tsdbInfo
(
"vgId:%d %s success, e
type:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
fs
->
etype
);
}
return
code
;
}
...
...
@@ -402,6 +402,23 @@ static int32_t update_fs_if_needed(STFileSystem *pFS) {
return
0
;
}
static
int32_t
tsdbFSDupState
(
const
TFileSetArray
*
src
,
TFileSetArray
*
dst
)
{
TARRAY2_CLEAR
(
dst
,
tsdbTFileSetClear
);
const
STFileSet
*
fset1
;
TARRAY2_FOREACH
(
src
,
fset1
)
{
STFileSet
*
fset
;
int32_t
code
=
tsdbTFileSetInitEx
(
fset1
,
&
fset
);
if
(
code
)
return
code
;
code
=
TARRAY2_APPEND
(
dst
,
fset
);
if
(
code
)
return
code
;
}
return
0
;
}
static
int32_t
open_fs
(
STFileSystem
*
fs
,
int8_t
rollback
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -430,8 +447,8 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
code
=
abort_edit
(
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
// code = load_fs(cCurrent,
fs->nstate);
//
TSDB_CHECK_CODE(code, lino, _exit);
code
=
load_fs
(
cCurrent
,
&
fs
->
nstate
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
commit_edit
(
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
@@ -443,6 +460,9 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbFSDupState
(
&
fs
->
cstate
,
&
fs
->
nstate
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
scan_and_fix_fs
(
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
else
{
...
...
@@ -546,36 +566,41 @@ int32_t tsdbFSAllocEid(STFileSystem *pFS, int64_t *eid) {
return
0
;
}
int32_t
tsdbFSEditBegin
(
STFileSystem
*
fs
,
int64_t
eid
,
const
SArray
*
aFileOp
,
EFEditT
etype
)
{
// TODO: remove eid
int32_t
tsdbFSEditBegin
(
STFileSystem
*
fs
,
const
SArray
*
aFileOp
,
EFEditT
etype
)
{
int32_t
code
=
0
;
int32_t
lino
;
char
current_t
[
TSDB_FILENAME_LEN
];
if
(
etype
==
TSDB_FEDIT_COMMIT
)
{
current_fname
(
fs
->
pTsdb
,
current_t
,
TSDB_FCURRENT_C
);
}
else
{
current_fname
(
fs
->
pTsdb
,
current_t
,
TSDB_FCURRENT_M
);
switch
(
etype
)
{
case
TSDB_FEDIT_COMMIT
:
current_fname
(
fs
->
pTsdb
,
current_t
,
TSDB_FCURRENT_C
);
break
;
case
TSDB_FEDIT_MERGE
:
current_fname
(
fs
->
pTsdb
,
current_t
,
TSDB_FCURRENT_M
);
break
;
default:
ASSERT
(
0
);
}
tsem_wait
(
&
fs
->
canEdit
);
fs
->
etype
=
etype
;
fs
->
eid
=
eid
;
// edit
code
=
edit_fs
(
fs
,
aFileOp
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// save fs
// code = save_fs(
fs->nstate, current_t);
//
TSDB_CHECK_CODE(code, lino, _exit);
code
=
save_fs
(
&
fs
->
nstate
,
current_t
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
tsdbError
(
"vgId:%d %s failed at line %d since %s, e
id:%"
PRId64
" etype:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
),
fs
->
eid
,
etype
);
tsdbError
(
"vgId:%d %s failed at line %d since %s, e
type:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
lino
,
tstrerror
(
code
)
,
etype
);
}
else
{
tsdbInfo
(
"vgId:%d %s done, e
id:%"
PRId64
" etype:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
fs
->
eid
,
etype
);
tsdbInfo
(
"vgId:%d %s done, e
type:%d"
,
TD_VID
(
fs
->
pTsdb
->
pVnode
),
__func__
,
etype
);
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录