Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0e97340e
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看板
提交
0e97340e
编写于
6月 21, 2023
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
4a1010cd
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
275 addition
and
55 deletion
+275
-55
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+38
-38
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFS2.c
source/dnode/vnode/src/tsdb/tsdbFS2.c
+6
-16
source/dnode/vnode/src/tsdb/tsdbFS2.h
source/dnode/vnode/src/tsdb/tsdbFS2.h
+6
-0
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
+190
-0
source/dnode/vnode/src/tsdb/tsdbUpgrade.h
source/dnode/vnode/src/tsdb/tsdbUpgrade.h
+34
-0
未找到文件。
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
0e97340e
...
...
@@ -16,9 +16,9 @@
#ifndef _TD_VNODE_TSDB_H_
#define _TD_VNODE_TSDB_H_
//#include "../tsdb/tsdbFile2.h"
//#include "../tsdb/tsdbMerge.h"
//#include "../tsdb/tsdbSttFileRW.h"
//
#include "../tsdb/tsdbFile2.h"
//
#include "../tsdb/tsdbMerge.h"
//
#include "../tsdb/tsdbSttFileRW.h"
#include "tsimplehash.h"
#include "vnodeInt.h"
...
...
@@ -703,20 +703,20 @@ typedef struct {
typedef
struct
SSttBlockLoadInfo
{
SBlockData
blockData
[
2
];
void
*
pBlockArray
;
SArray
*
aSttBlk
;
int32_t
blockIndex
[
2
];
// to denote the loaded block in the corresponding position.
int32_t
currentLoadBlockIndex
;
int32_t
loadBlocks
;
double
elapsedTime
;
STSchema
*
pSchema
;
int16_t
*
colIds
;
int32_t
numOfCols
;
bool
checkRemainingRow
;
bool
isLast
;
bool
sttBlockLoaded
;
int32_t
numOfStt
;
void
*
pBlockArray
;
SArray
*
aSttBlk
;
int32_t
blockIndex
[
2
];
// to denote the loaded block in the corresponding position.
int32_t
currentLoadBlockIndex
;
int32_t
loadBlocks
;
double
elapsedTime
;
STSchema
*
pSchema
;
int16_t
*
colIds
;
int32_t
numOfCols
;
bool
checkRemainingRow
;
bool
isLast
;
bool
sttBlockLoaded
;
int32_t
numOfStt
;
// keep the last access position, this position may be used to reduce the binary times for
// starting last block data for a new table
...
...
@@ -775,19 +775,19 @@ struct SDiskDataBuilder {
};
typedef
struct
SLDataIter
{
SRBTreeNode
node
;
SSttBlk
*
pSttBlk
;
int32_t
iStt
;
int8_t
backward
;
int32_t
iSttBlk
;
int32_t
iRow
;
SRowInfo
rInfo
;
uint64_t
uid
;
STimeWindow
timeWindow
;
SVersionRange
verRange
;
SSttBlockLoadInfo
*
pBlockLoadInfo
;
bool
ignoreEarlierTs
;
struct
SSttFileReader
*
pReader
;
SRBTreeNode
node
;
SSttBlk
*
pSttBlk
;
int32_t
iStt
;
int8_t
backward
;
int32_t
iSttBlk
;
int32_t
iRow
;
SRowInfo
rInfo
;
uint64_t
uid
;
STimeWindow
timeWindow
;
SVersionRange
verRange
;
SSttBlockLoadInfo
*
pBlockLoadInfo
;
bool
ignoreEarlierTs
;
struct
SSttFileReader
*
pReader
;
}
SLDataIter
;
#define tMergeTreeGetRow(_t) (&((_t)->pIter->rInfo.row))
...
...
@@ -795,21 +795,21 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
);
int32_t
tMergeTreeOpen2
(
SMergeTree
*
pMTree
,
int8_t
backward
,
STsdb
*
pTsdb
,
uint64_t
suid
,
uint64_t
uid
,
int32_t
tMergeTreeOpen2
(
SMergeTree
*
pMTree
,
int8_t
backward
,
STsdb
*
pTsdb
,
uint64_t
suid
,
uint64_t
uid
,
STimeWindow
*
pTimeWindow
,
SVersionRange
*
pVerRange
,
SSttBlockLoadInfo
*
pBlockLoadInfo
,
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
,
void
*
pCurrentFileSet
);
bool
destroyLoadInfo
,
const
char
*
idStr
,
bool
strictTimeRange
,
SLDataIter
*
pLDataIter
,
void
*
pCurrentFileSet
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
bool
tMergeTreeIgnoreEarlierTs
(
SMergeTree
*
pMTree
);
void
tMergeTreeClose
(
SMergeTree
*
pMTree
);
void
tMergeTreeAddIter
(
SMergeTree
*
pMTree
,
SLDataIter
*
pIter
);
bool
tMergeTreeNext
(
SMergeTree
*
pMTree
);
bool
tMergeTreeIgnoreEarlierTs
(
SMergeTree
*
pMTree
);
void
tMergeTreeClose
(
SMergeTree
*
pMTree
);
SSttBlockLoadInfo
*
tCreateLastBlockLoadInfo
(
STSchema
*
pSchema
,
int16_t
*
colList
,
int32_t
numOfCols
,
int32_t
numOfStt
);
void
resetLastBlockLoadInfo
(
SSttBlockLoadInfo
*
pLoadInfo
);
void
getLastBlockLoadInfo
(
SSttBlockLoadInfo
*
pLoadInfo
,
int64_t
*
blocks
,
double
*
el
);
void
*
destroyLastBlockLoadInfo
(
SSttBlockLoadInfo
*
pLoadInfo
);
void
destroySttBlockReader
(
SLDataIter
*
pLDataIter
,
int32_t
numOfIter
);
void
destroySttBlockReader
(
SLDataIter
*
pLDataIter
,
int32_t
numOfIter
);
// tsdbCache ==============================================================================================
typedef
struct
SCacheRowsReader
{
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
0e97340e
...
...
@@ -269,7 +269,7 @@ int32_t tDFileSetCmprFn(const void *p1, const void *p2) {
return
0
;
}
static
void
tsdbGetCurrentFName
(
STsdb
*
pTsdb
,
char
*
current
,
char
*
current_t
)
{
void
tsdbGetCurrentFName
(
STsdb
*
pTsdb
,
char
*
current
,
char
*
current_t
)
{
SVnode
*
pVnode
=
pTsdb
->
pVnode
;
if
(
pVnode
->
pTfs
)
{
if
(
current
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbFS2.c
浏览文件 @
0e97340e
...
...
@@ -14,6 +14,7 @@
*/
#include "tsdbFS2.h"
#include "tsdbUpgrade.h"
extern
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
);
extern
int
vnodeScheduleTaskEx
(
int
tpid
,
int
(
*
execute
)(
void
*
),
void
*
arg
);
...
...
@@ -28,12 +29,6 @@ enum {
TSDB_FS_STATE_CLOSE
,
};
typedef
enum
{
TSDB_FCURRENT
=
1
,
TSDB_FCURRENT_C
,
// for commit
TSDB_FCURRENT_M
,
// for merge
}
EFCurrentT
;
static
const
char
*
gCurrentFname
[]
=
{
[
TSDB_FCURRENT
]
=
"current.json"
,
[
TSDB_FCURRENT_C
]
=
"current.c.json"
,
...
...
@@ -73,7 +68,7 @@ static int32_t destroy_fs(STFileSystem **fs) {
return
0
;
}
static
int32_t
current_fname
(
STsdb
*
pTsdb
,
char
*
fname
,
EFCurrentT
ftype
)
{
int32_t
current_fname
(
STsdb
*
pTsdb
,
char
*
fname
,
EFCurrentT
ftype
)
{
if
(
pTsdb
->
pVnode
->
pTfs
)
{
snprintf
(
fname
,
//
TSDB_FILENAME_LEN
,
//
...
...
@@ -161,7 +156,7 @@ _exit:
return
code
;
}
static
int32_t
save_fs
(
const
TFileSetArray
*
arr
,
const
char
*
fname
)
{
int32_t
save_fs
(
const
TFileSetArray
*
arr
,
const
char
*
fname
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
...
...
@@ -375,11 +370,6 @@ static int32_t tsdbFSScanAndFix(STFileSystem *fs) {
return
0
;
}
static
int32_t
update_fs_if_needed
(
STFileSystem
*
pFS
)
{
// TODO
return
0
;
}
static
int32_t
tsdbFSDupState
(
STFileSystem
*
fs
)
{
int32_t
code
;
...
...
@@ -405,9 +395,6 @@ static int32_t open_fs(STFileSystem *fs, int8_t rollback) {
int32_t
lino
=
0
;
STsdb
*
pTsdb
=
fs
->
tsdb
;
code
=
update_fs_if_needed
(
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
char
fCurrent
[
TSDB_FILENAME_LEN
];
char
cCurrent
[
TSDB_FILENAME_LEN
];
char
mCurrent
[
TSDB_FILENAME_LEN
];
...
...
@@ -530,6 +517,9 @@ int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **fs, int8_t rollback) {
int32_t
code
;
int32_t
lino
;
code
=
tsdbCheckAndUpgradeFileSystem
(
pTsdb
,
rollback
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
code
=
create_fs
(
pTsdb
,
fs
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
...
...
source/dnode/vnode/src/tsdb/tsdbFS2.h
浏览文件 @
0e97340e
...
...
@@ -38,6 +38,12 @@ typedef enum {
TSDB_BG_TASK_COMPACT
,
}
EFSBgTaskT
;
typedef
enum
{
TSDB_FCURRENT
=
1
,
TSDB_FCURRENT_C
,
// for commit
TSDB_FCURRENT_M
,
// for merge
}
EFCurrentT
;
/* Exposed APIs */
// open/close
int32_t
tsdbOpenFS
(
STsdb
*
pTsdb
,
STFileSystem
**
fs
,
int8_t
rollback
);
...
...
source/dnode/vnode/src/tsdb/tsdbUpgrade.c
0 → 100644
浏览文件 @
0e97340e
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tsdbUpgrade.h"
// old
extern
void
tsdbGetCurrentFName
(
STsdb
*
pTsdb
,
char
*
current
,
char
*
current_t
);
// new
extern
int32_t
save_fs
(
const
TFileSetArray
*
arr
,
const
char
*
fname
);
extern
int32_t
current_fname
(
STsdb
*
pTsdb
,
char
*
fname
,
EFCurrentT
ftype
);
static
int32_t
tsdbUpgradeFileSet
(
STsdb
*
tsdb
,
SDFileSet
*
pDFileSet
,
TFileSetArray
*
fileSetArray
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
SDataFReader
*
reader
;
code
=
tsdbDataFReaderOpen
(
&
reader
,
tsdb
,
pDFileSet
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// .head
{
SArray
*
aBlockIdx
=
NULL
;
SMapData
mDataBlk
[
1
]
=
{
0
};
SBrinBlock
brinBlock
[
1
]
=
{
0
};
TBrinBlkArray
brinBlkArray
[
1
]
=
{
0
};
if
((
aBlockIdx
=
taosArrayInit
(
0
,
sizeof
(
SBlockIdx
)))
==
NULL
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbReadBlockIdx
(
reader
,
aBlockIdx
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
aBlockIdx
);
++
i
)
{
SBlockIdx
*
pBlockIdx
=
taosArrayGet
(
aBlockIdx
,
i
);
code
=
tsdbReadDataBlk
(
reader
,
pBlockIdx
,
mDataBlk
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
for
(
int32_t
j
=
0
;
j
<
mDataBlk
->
nItem
;
++
j
)
{
SDataBlk
dataBlk
[
1
];
tMapDataGetItemByIdx
(
mDataBlk
,
j
,
dataBlk
,
tGetDataBlk
);
SBrinRecord
record
=
{
.
suid
=
pBlockIdx
->
suid
,
.
uid
=
pBlockIdx
->
uid
,
.
firstKey
=
dataBlk
->
minKey
.
ts
,
.
firstKeyVer
=
dataBlk
->
minKey
.
version
,
.
lastKey
=
dataBlk
->
maxKey
.
ts
,
.
lastKeyVer
=
dataBlk
->
maxKey
.
version
,
.
minVer
=
dataBlk
->
minVer
,
.
maxVer
=
dataBlk
->
maxVer
,
.
blockOffset
=
dataBlk
->
aSubBlock
->
offset
,
.
smaOffset
=
dataBlk
->
smaInfo
.
offset
,
.
blockSize
=
dataBlk
->
aSubBlock
->
szBlock
,
.
blockKeySize
=
dataBlk
->
aSubBlock
->
szKey
,
.
smaSize
=
dataBlk
->
smaInfo
.
size
,
.
numRow
=
dataBlk
->
nRow
,
.
count
=
dataBlk
->
nRow
,
};
if
(
dataBlk
->
hasDup
)
{
ASSERT
(
0
);
// TODO: need to get count
// record.count = 0;
}
code
=
tBrinBlockPut
(
brinBlock
,
&
record
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
if
(
BRIN_BLOCK_SIZE
(
brinBlock
)
>=
tsdb
->
pVnode
->
config
.
tsdbCfg
.
maxRows
)
{
// TODO
tBrinBlockClear
(
brinBlock
);
}
}
}
if
(
BRIN_BLOCK_SIZE
(
brinBlock
)
>
0
)
{
// TODO
ASSERT
(
0
);
}
// TODO
ASSERT
(
0
);
TARRAY2_DESTROY
(
brinBlkArray
,
NULL
);
tBrinBlockDestroy
(
brinBlock
);
taosArrayDestroy
(
aBlockIdx
);
tMapDataClear
(
mDataBlk
);
}
// .data
// .sma
// .stt
for
(
int32_t
i
=
0
;
i
<
pDFileSet
->
nSttF
;
++
i
)
{
// TODO
}
tsdbDataFReaderClose
(
&
reader
);
_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
ASSERT
(
0
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
tsdb
->
pVnode
),
lino
,
code
);
}
return
code
;
}
static
int32_t
tsdbDoUpgradeFileSystem
(
STsdb
*
tsdb
,
int8_t
rollback
)
{
int32_t
code
=
0
;
int32_t
lino
=
0
;
TFileSetArray
fileSetArray
[
1
]
=
{
0
};
// load old file system and convert
code
=
tsdbFSOpen
(
tsdb
,
rollback
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tsdb
->
fs
.
aDFileSet
);
i
++
)
{
SDFileSet
*
pDFileSet
=
taosArrayGet
(
tsdb
->
fs
.
aDFileSet
,
i
);
code
=
tsdbUpgradeFileSet
(
tsdb
,
pDFileSet
,
fileSetArray
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
if
(
tsdb
->
fs
.
pDelFile
!=
NULL
)
{
code
=
tsdbUpgradeTombFile
(
tsdb
,
tsdb
->
fs
.
pDelFile
,
fileSetArray
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
}
code
=
tsdbFSClose
(
tsdb
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
// save new file system
char
fname
[
TSDB_FILENAME_LEN
];
current_fname
(
tsdb
,
fname
,
TSDB_FCURRENT
);
code
=
save_fs
(
fileSetArray
,
NULL
);
TSDB_CHECK_CODE
(
code
,
lino
,
_exit
);
_exit:
if
(
code
)
{
TSDB_ERROR_LOG
(
TD_VID
(
tsdb
->
pVnode
),
lino
,
code
);
}
return
code
;
}
int32_t
tsdbCheckAndUpgradeFileSystem
(
STsdb
*
tsdb
,
int8_t
rollback
)
{
char
fname
[
TSDB_FILENAME_LEN
];
tsdbGetCurrentFName
(
tsdb
,
fname
,
NULL
);
if
(
!
taosCheckExistFile
(
fname
))
return
0
;
int32_t
code
=
tsdbDoUpgradeFileSystem
(
tsdb
,
rollback
);
if
(
code
)
return
code
;
taosRemoveFile
(
fname
);
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/tsdb/tsdbUpgrade.h
0 → 100644
浏览文件 @
0e97340e
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tsdb.h"
#include "tsdbDef.h"
#include "tsdbFS2.h"
#include "tsdbUtil2.h"
#ifndef _TSDB_UPGRADE_H_
#define _TSDB_UPGRADE_H_
#ifdef __cplusplus
extern
"C"
{
#endif
int32_t
tsdbCheckAndUpgradeFileSystem
(
STsdb
*
tsdb
,
int8_t
rollback
);
#ifdef __cplusplus
}
#endif
#endif
/*_TSDB_UPGRADE_H_*/
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录