Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bbc2ba9f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
bbc2ba9f
编写于
6月 05, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact TSDB
上级
40a39656
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
70 deletion
+54
-70
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+27
-63
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+27
-7
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
bbc2ba9f
...
...
@@ -101,7 +101,28 @@ int tsdbCopyDFileSet(SDFileSet *pSrc, SDFileSet *pDest);
void
tsdbGetFidKeyRange
(
int
days
,
int8_t
precision
,
int
fid
,
TSKEY
*
minKey
,
TSKEY
*
maxKey
);
// tsdbFS.c ==============================================================================================
typedef
struct
STsdbFS
STsdbFS
;
typedef
struct
STsdbFS
STsdbFS
;
typedef
struct
SFSIter
SFSIter
;
typedef
struct
STsdbFSMeta
STsdbFSMeta
;
STsdbFS
*
tsdbNewFS
(
const
STsdbKeepCfg
*
pCfg
);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
int
tsdbOpenFS
(
STsdb
*
pRepo
);
void
tsdbCloseFS
(
STsdb
*
pRepo
);
void
tsdbStartFSTxn
(
STsdb
*
pRepo
,
int64_t
pointsAdd
,
int64_t
storageAdd
);
int
tsdbEndFSTxn
(
STsdb
*
pRepo
);
int
tsdbEndFSTxnWithError
(
STsdbFS
*
pfs
);
void
tsdbUpdateFSTxnMeta
(
STsdbFS
*
pfs
,
STsdbFSMeta
*
pMeta
);
// void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile);
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
);
void
tsdbFSIterInit
(
SFSIter
*
pIter
,
STsdbFS
*
pfs
,
int
direction
);
void
tsdbFSIterSeek
(
SFSIter
*
pIter
,
int
fid
);
SDFileSet
*
tsdbFSIterNext
(
SFSIter
*
pIter
);
int
tsdbLoadMetaCache
(
STsdb
*
pRepo
,
bool
recoverMeta
);
int
tsdbRLockFS
(
STsdbFS
*
pFs
);
int
tsdbWLockFS
(
STsdbFS
*
pFs
);
int
tsdbUnLockFS
(
STsdbFS
*
pFs
);
// tsdbMemTable ================
typedef
struct
STbData
STbData
;
...
...
@@ -208,11 +229,11 @@ struct STsdbMemTable {
SHashObj
*
pHashIdx
;
};
typedef
struct
{
struct
STsdbFSMeta
{
uint32_t
version
;
// Commit version from 0 to increase
int64_t
totalPoints
;
// total points
int64_t
totalStorage
;
// Uncompressed total storage
}
STsdbFSMeta
;
};
// ==================
typedef
struct
{
...
...
@@ -573,21 +594,7 @@ static FORCE_INLINE uint32_t tsdbGetDFSVersion(TSDB_FILE_T fType) { // latest v
// =============== SDFileSet
typedef
struct
{
int
fid
;
int8_t
state
;
uint8_t
ver
;
uint16_t
reserve
;
#if 0
SDFInfo info;
#endif
STfsFile
f
;
TdFilePtr
pFile
;
}
SSFile
;
// files split by days with fid
#define TSDB_LATEST_FSET_VER 0
#define TSDB_LATEST_FSET_VER 0
#define TSDB_FSET_FID(s) ((s)->fid)
#define TSDB_FSET_STATE(s) ((s)->state)
#define TSDB_FSET_VER(s) ((s)->ver)
...
...
@@ -634,61 +641,18 @@ typedef struct {
#define FS_VERSION(pfs) ((pfs)->cstatus->meta.version)
#define FS_TXN_VERSION(pfs) ((pfs)->nstatus->meta.version)
typedef
struct
{
struct
SFSIter
{
int
direction
;
uint64_t
version
;
// current FS version
STsdbFS
*
pfs
;
int
index
;
// used to position next fset when version the same
int
fid
;
// used to seek when version is changed
SDFileSet
*
pSet
;
}
SFSIter
;
};
#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC
#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC
STsdbFS
*
tsdbNewFS
(
const
STsdbKeepCfg
*
pCfg
);
void
*
tsdbFreeFS
(
STsdbFS
*
pfs
);
int
tsdbOpenFS
(
STsdb
*
pRepo
);
void
tsdbCloseFS
(
STsdb
*
pRepo
);
void
tsdbStartFSTxn
(
STsdb
*
pRepo
,
int64_t
pointsAdd
,
int64_t
storageAdd
);
int
tsdbEndFSTxn
(
STsdb
*
pRepo
);
int
tsdbEndFSTxnWithError
(
STsdbFS
*
pfs
);
void
tsdbUpdateFSTxnMeta
(
STsdbFS
*
pfs
,
STsdbFSMeta
*
pMeta
);
// void tsdbUpdateMFile(STsdbFS *pfs, const SMFile *pMFile);
int
tsdbUpdateDFileSet
(
STsdbFS
*
pfs
,
const
SDFileSet
*
pSet
);
void
tsdbFSIterInit
(
SFSIter
*
pIter
,
STsdbFS
*
pfs
,
int
direction
);
void
tsdbFSIterSeek
(
SFSIter
*
pIter
,
int
fid
);
SDFileSet
*
tsdbFSIterNext
(
SFSIter
*
pIter
);
int
tsdbLoadMetaCache
(
STsdb
*
pRepo
,
bool
recoverMeta
);
static
FORCE_INLINE
int
tsdbRLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbWLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbUnLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
struct
TSDBROW
{
int64_t
version
;
STSRow2
tsRow
;
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
bbc2ba9f
...
...
@@ -952,13 +952,6 @@ static int tsdbRestoreDFileSet(STsdb *pRepo) {
}
static
int
tsdbRestoreCurrent
(
STsdb
*
pRepo
)
{
// // Loop to recover mfile
// if (tsdbRestoreMeta(pRepo) < 0) {
// tsdbError("vgId:%d, failed to restore current since %s", REPO_ID(pRepo), tstrerror(terrno));
// return -1;
// }
// Loop to recover dfile set
if
(
tsdbRestoreDFileSet
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d, failed to restore DFileSet since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
...
...
@@ -1041,3 +1034,30 @@ static void tsdbScanAndTryFixDFilesHeader(STsdb *pRepo, int32_t *nExpired) {
tsdbCloseDFileSet
(
&
fset
);
}
}
int
tsdbRLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockRdlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
int
tsdbWLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockWrlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
int
tsdbUnLockFS
(
STsdbFS
*
pFs
)
{
int
code
=
taosThreadRwlockUnlock
(
&
(
pFs
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录