Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e6510847
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看板
提交
e6510847
编写于
9月 07, 2021
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dfileset compatibility
上级
9c0f0525
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
143 addition
and
10 deletion
+143
-10
src/tsdb/inc/tsdbFile.h
src/tsdb/inc/tsdbFile.h
+1
-1
src/tsdb/inc/tsdbReadImpl.h
src/tsdb/inc/tsdbReadImpl.h
+4
-4
src/tsdb/src/tsdbFS.c
src/tsdb/src/tsdbFS.c
+136
-1
src/tsdb/src/tsdbFile.c
src/tsdb/src/tsdbFile.c
+1
-4
src/wal/src/walWrite.c
src/wal/src/walWrite.c
+1
-0
未找到文件。
src/tsdb/inc/tsdbFile.h
浏览文件 @
e6510847
...
...
@@ -168,7 +168,6 @@ typedef struct {
uint32_t
offset
;
uint64_t
size
;
uint64_t
tombSize
;
uint32_t
fver
;
}
SDFInfo
;
typedef
struct
{
...
...
@@ -176,6 +175,7 @@ typedef struct {
TFILE
f
;
int
fd
;
uint8_t
state
;
uint32_t
fver
;
}
SDFile
;
void
tsdbInitDFile
(
SDFile
*
pDFile
,
SDiskID
did
,
int
vid
,
int
fid
,
uint32_t
ver
,
TSDB_FILE_T
ftype
);
...
...
src/tsdb/inc/tsdbReadImpl.h
浏览文件 @
e6510847
...
...
@@ -42,16 +42,16 @@ typedef struct {
int32_t
numOfRows
:
24
;
int32_t
len
;
int32_t
keyLen
;
// key column length, keyOffset = offset+sizeof(SBlockData)+sizeof(SBlockCol)*numOfCols
int16_t
numOfSubBlocks
;
int16_t
numOfCols
;
// not including timestamp column
TSKEY
keyFirst
;
TSKEY
keyLast
;
#ifdef __TD_6117__
int64_t
hasAggr
:
1
;
int64_t
blkVer
:
7
;
int64_t
aggrOffset
:
56
;
int32_t
aggrLen
;
#endif
int16_t
numOfSubBlocks
;
int16_t
numOfCols
;
// not including timestamp column
TSKEY
keyFirst
;
TSKEY
keyLast
;
}
SBlock
;
typedef
struct
{
...
...
src/tsdb/src/tsdbFS.c
浏览文件 @
e6510847
...
...
@@ -1166,6 +1166,7 @@ static int tsdbFetchTFileSet(STsdbRepo *pRepo, SArray **fArray) {
return
0
;
}
#if 0
static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
const TFILE *pf = NULL;
SArray * fArray = NULL;
...
...
@@ -1188,7 +1189,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
TSDB_FSET_SET_INIT(&fset);
// Loop to recover ONE fset
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
TSDB_FILE_MAX
;
ftype
++
)
{
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX
- 1
; ftype++) {
SDFile *pDFile = TSDB_DFILE_IN_SET(&fset, ftype);
if (index >= taosArrayGetSize(fArray)) {
...
...
@@ -1268,6 +1269,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
}
tsdbInfo("vgId:%d FSET %d is restored", REPO_ID(pRepo), fset.fid);
fset.nFiles = 3;
taosArrayPush(pfs->cstatus->df, &fset);
}
...
...
@@ -1276,6 +1278,139 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
return 0;
}
#endif
#if 1
static
int
tsdbRestoreDFileSet
(
STsdbRepo
*
pRepo
)
{
const
TFILE
*
pf
=
NULL
;
SArray
*
fArray
=
NULL
;
STsdbFS
*
pfs
=
REPO_FS
(
pRepo
);
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
size_t
fArraySize
=
0
;
tsdbGetDataDir
(
REPO_ID
(
pRepo
),
dataDir
);
if
(
tsdbFetchTFileSet
(
pRepo
,
&
fArray
)
<
0
)
{
tsdbError
(
"vgId:%d failed to fetch TFileSet from %s to restore since %s"
,
REPO_ID
(
pRepo
),
dataDir
,
tstrerror
(
terrno
));
return
-
1
;
}
if
((
fArraySize
=
taosArrayGetSize
(
fArray
))
<=
0
)
{
tsdbInfo
(
"vgId:%d size of DFileSet from %s is %"
PRIu32
,
REPO_ID
(
pRepo
),
dataDir
,
(
uint32_t
)
fArraySize
);
return
0
;
}
// Loop to recover each file set
SDFileSet
fset
=
{
0
};
bool
isOneFSetFinish
=
false
;
// one fileset ends when (1) the array ends or (2) encounter different fid
for
(
size_t
index
=
0
;
index
<
fArraySize
;
++
index
)
{
int
tvid
=
-
1
,
tfid
=
-
1
;
TSDB_FILE_T
ttype
=
TSDB_FILE_MAX
;
uint32_t
tversion
=
-
1
;
char
bname
[
TSDB_FILENAME_LEN
]
=
"
\0
"
;
pf
=
taosArrayGet
(
fArray
,
index
);
tfsbasename
(
pf
,
bname
);
tsdbParseDFilename
(
bname
,
&
tvid
,
&
tfid
,
&
ttype
,
&
tversion
);
ASSERT
(
tvid
==
REPO_ID
(
pRepo
));
SDFile
*
pDFile
=
TSDB_DFILE_IN_SET
(
&
fset
,
ttype
);
if
(
tfid
<
pRepo
->
rtn
.
minFid
)
{
// skip the file expired
continue
;
}
if
(
index
==
0
)
{
memset
(
&
fset
,
0
,
sizeof
(
SDFileSet
));
TSDB_FSET_SET_INIT
(
&
fset
);
fset
.
nFiles
=
1
;
fset
.
fid
=
tfid
;
pDFile
->
f
=
*
pf
;
isOneFSetFinish
=
false
;
}
else
{
if
(
fset
.
fid
==
tfid
)
{
++
fset
.
nFiles
;
pDFile
->
f
=
*
pf
;
// (1) the array ends
if
((
index
==
fArraySize
-
1
)
&&
(
fset
.
nFiles
>=
TSDB_FILE_MIN
))
{
tsdbInfo
(
"vgId:%d DFileSet %d is fetched, nFiles=%"
PRIu8
,
REPO_ID
(
pRepo
),
fset
.
fid
,
fset
.
nFiles
);
isOneFSetFinish
=
true
;
}
}
else
{
// (2) encounter different fid
if
(
fset
.
nFiles
>=
TSDB_FILE_MIN
)
{
tsdbInfo
(
"vgId:%d DFileSet %d is fetched, nFiles=%"
PRIu8
,
REPO_ID
(
pRepo
),
fset
.
fid
,
fset
.
nFiles
);
isOneFSetFinish
=
true
;
}
else
{
// next FSet
memset
(
&
fset
,
0
,
sizeof
(
SDFileSet
));
TSDB_FSET_SET_INIT
(
&
fset
);
fset
.
nFiles
=
1
;
fset
.
fid
=
tfid
;
pDFile
->
f
=
*
pf
;
isOneFSetFinish
=
false
;
continue
;
}
}
}
if
(
isOneFSetFinish
)
{
for
(
TSDB_FILE_T
ftype
=
0
;
ftype
<
fset
.
nFiles
;
++
ftype
)
{
SDFile
*
pDFile1
=
TSDB_DFILE_IN_SET
(
&
fset
,
ftype
);
if
(
tsdbOpenDFile
(
pDFile1
,
O_RDONLY
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open DFile %s since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile1
),
tstrerror
(
terrno
));
taosArrayDestroy
(
fArray
);
return
-
1
;
}
if
(
tsdbLoadDFileHeader
(
pDFile1
,
&
(
pDFile1
->
info
))
<
0
)
{
tsdbError
(
"vgId:%d failed to load DFile %s header since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile1
),
tstrerror
(
terrno
));
taosArrayDestroy
(
fArray
);
return
-
1
;
}
if
(
tsdbForceKeepFile
)
{
struct
stat
tfstat
;
// Get real file size
if
(
fstat
(
pDFile1
->
fd
,
&
tfstat
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
taosArrayDestroy
(
fArray
);
return
-
1
;
}
if
(
pDFile1
->
info
.
size
!=
tfstat
.
st_size
)
{
int64_t
tfsize
=
pDFile1
->
info
.
size
;
pDFile1
->
info
.
size
=
tfstat
.
st_size
;
tsdbInfo
(
"vgId:%d file %s header size is changed from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile1
),
tfsize
,
pDFile1
->
info
.
size
);
}
}
tsdbCloseDFile
(
pDFile1
);
}
tsdbInfo
(
"vgId:%d FSET %d is restored"
,
REPO_ID
(
pRepo
),
fset
.
fid
);
taosArrayPush
(
pfs
->
cstatus
->
df
,
&
fset
);
// next FSet
memset
(
&
fset
,
0
,
sizeof
(
SDFileSet
));
TSDB_FSET_SET_INIT
(
&
fset
);
fset
.
nFiles
=
1
;
fset
.
fid
=
tfid
;
pDFile
->
f
=
*
pf
;
isOneFSetFinish
=
false
;
}
}
// Resource release
taosArrayDestroy
(
fArray
);
return
0
;
}
#endif
static
int
tsdbRestoreCurrent
(
STsdbRepo
*
pRepo
)
{
// Loop to recover mfile
...
...
src/tsdb/src/tsdbFile.c
浏览文件 @
e6510847
...
...
@@ -302,7 +302,6 @@ void tsdbInitDFile(SDFile *pDFile, SDiskID did, int vid, int fid, uint32_t ver,
memset
(
&
(
pDFile
->
info
),
0
,
sizeof
(
pDFile
->
info
));
pDFile
->
info
.
magic
=
TSDB_FILE_INIT_MAGIC
;
pDFile
->
info
.
fver
=
tsdbGetDFSVersion
(
ftype
);
tsdbGetFilename
(
vid
,
fid
,
ver
,
ftype
,
fname
);
tfsInitFile
(
&
(
pDFile
->
f
),
did
.
level
,
did
.
id
,
fname
);
...
...
@@ -468,7 +467,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
void
*
pBuf
=
buf
;
// pBuf = taosDecodeFixedU32(pBuf, &_version
);
pBuf
=
taosDecodeFixedU32
(
pBuf
,
&
(
pDFile
->
fver
)
);
pBuf
=
tsdbDecodeDFInfo
(
pBuf
,
pInfo
);
return
0
;
}
...
...
@@ -528,7 +527,6 @@ static int tsdbScanAndTryFixDFile(STsdbRepo *pRepo, SDFile *pDFile) {
static
int
tsdbEncodeDFInfo
(
void
**
buf
,
SDFInfo
*
pInfo
)
{
int
tlen
=
0
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
fver
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
magic
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
len
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pInfo
->
totalBlocks
);
...
...
@@ -541,7 +539,6 @@ static int tsdbEncodeDFInfo(void **buf, SDFInfo *pInfo) {
}
static
void
*
tsdbDecodeDFInfo
(
void
*
buf
,
SDFInfo
*
pInfo
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
fver
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
magic
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
len
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pInfo
->
totalBlocks
));
...
...
src/wal/src/walWrite.c
浏览文件 @
e6510847
...
...
@@ -411,6 +411,7 @@ static int walSMemRowCheck(SWalHead *pHead) {
pWalHead
->
len
=
pWalHead
->
len
+
lenExpand
;
}
ASSERT
((
sizeof
(
SWalHead
)
+
pWalHead
->
len
)
<=
WAL_MAX_SIZE
);
memcpy
(
pHead
,
pWalHead
,
sizeof
(
SWalHead
)
+
pWalHead
->
len
);
tfree
(
pWalHead
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录