Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f4399816
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f4399816
编写于
2月 26, 2021
作者:
H
huili
提交者:
GitHub
2月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5276 from taosdata/hotfix/TD-3075
[TD-3075]<hotfix>: fix SBlockCol offset overflow
上级
16f30a5f
5978d708
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
23 deletion
+36
-23
src/tsdb/inc/tsdbReadImpl.h
src/tsdb/inc/tsdbReadImpl.h
+24
-11
src/tsdb/src/tsdbCommit.c
src/tsdb/src/tsdbCommit.c
+6
-6
src/tsdb/src/tsdbReadImpl.c
src/tsdb/src/tsdbReadImpl.c
+6
-6
未找到文件。
src/tsdb/inc/tsdbReadImpl.h
浏览文件 @
f4399816
...
@@ -49,19 +49,32 @@ typedef struct {
...
@@ -49,19 +49,32 @@ typedef struct {
}
SBlockInfo
;
}
SBlockInfo
;
typedef
struct
{
typedef
struct
{
int16_t
colId
;
int16_t
colId
;
int32_t
len
;
int32_t
len
;
int32_t
type
:
8
;
uint32_t
type
:
8
;
int32_t
offset
:
24
;
uint32_t
offset
:
24
;
int64_t
sum
;
int64_t
sum
;
int64_t
max
;
int64_t
max
;
int64_t
min
;
int64_t
min
;
int16_t
maxIndex
;
int16_t
maxIndex
;
int16_t
minIndex
;
int16_t
minIndex
;
int16_t
numOfNull
;
int16_t
numOfNull
;
char
padding
[
2
];
uint8_t
offsetH
;
char
padding
[
1
];
}
SBlockCol
;
}
SBlockCol
;
// Code here just for back-ward compatibility
static
FORCE_INLINE
void
tsdbSetBlockColOffset
(
SBlockCol
*
pBlockCol
,
uint32_t
offset
)
{
pBlockCol
->
offset
=
offset
&
((((
uint32_t
)
1
)
<<
24
)
-
1
);
pBlockCol
->
offsetH
=
(
uint8_t
)(
offset
>>
24
);
}
static
FORCE_INLINE
uint32_t
tsdbGetBlockColOffset
(
SBlockCol
*
pBlockCol
)
{
uint32_t
offset1
=
pBlockCol
->
offset
;
uint32_t
offset2
=
pBlockCol
->
offsetH
;
return
(
offset1
|
(
offset2
<<
24
));
}
typedef
struct
{
typedef
struct
{
int32_t
delimiter
;
// For recovery usage
int32_t
delimiter
;
// For recovery usage
int32_t
numOfCols
;
// For recovery usage
int32_t
numOfCols
;
// For recovery usage
...
...
src/tsdb/src/tsdbCommit.c
浏览文件 @
f4399816
...
@@ -781,11 +781,11 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
...
@@ -781,11 +781,11 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
ASSERT
(
nColsNotAllNull
>=
0
&&
nColsNotAllNull
<=
pDataCols
->
numOfCols
);
ASSERT
(
nColsNotAllNull
>=
0
&&
nColsNotAllNull
<=
pDataCols
->
numOfCols
);
// Compress the data if neccessary
// Compress the data if neccessary
int
tcol
=
0
;
// counter of not all NULL and written columns
int
tcol
=
0
;
// counter of not all NULL and written columns
int32_t
toffset
=
0
;
u
int32_t
toffset
=
0
;
int32_t
tsize
=
TSDB_BLOCK_STATIS_SIZE
(
nColsNotAllNull
);
int32_t
tsize
=
TSDB_BLOCK_STATIS_SIZE
(
nColsNotAllNull
);
int32_t
lsize
=
tsize
;
int32_t
lsize
=
tsize
;
int32_t
keyLen
=
0
;
int32_t
keyLen
=
0
;
for
(
int
ncol
=
0
;
ncol
<
pDataCols
->
numOfCols
;
ncol
++
)
{
for
(
int
ncol
=
0
;
ncol
<
pDataCols
->
numOfCols
;
ncol
++
)
{
// All not NULL columns finish
// All not NULL columns finish
if
(
ncol
!=
0
&&
tcol
>=
nColsNotAllNull
)
break
;
if
(
ncol
!=
0
&&
tcol
>=
nColsNotAllNull
)
break
;
...
@@ -829,7 +829,7 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
...
@@ -829,7 +829,7 @@ static int tsdbWriteBlock(SCommitH *pCommith, SDFile *pDFile, SDataCols *pDataCo
tsdbUpdateDFileMagic
(
pDFile
,
POINTER_SHIFT
(
tptr
,
flen
-
sizeof
(
TSCKSUM
)));
tsdbUpdateDFileMagic
(
pDFile
,
POINTER_SHIFT
(
tptr
,
flen
-
sizeof
(
TSCKSUM
)));
if
(
ncol
!=
0
)
{
if
(
ncol
!=
0
)
{
pBlockCol
->
offset
=
toffset
;
tsdbSetBlockColOffset
(
pBlockCol
,
toffset
)
;
pBlockCol
->
len
=
flen
;
pBlockCol
->
len
=
flen
;
tcol
++
;
tcol
++
;
}
else
{
}
else
{
...
...
src/tsdb/src/tsdbReadImpl.c
浏览文件 @
f4399816
...
@@ -466,14 +466,14 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
...
@@ -466,14 +466,14 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
continue
;
continue
;
}
}
int16_t
tcolId
=
0
;
int16_t
tcolId
=
0
;
int32_t
toffset
=
TSDB_KEY_COL_OFFSET
;
u
int32_t
toffset
=
TSDB_KEY_COL_OFFSET
;
int32_t
tlen
=
pBlock
->
keyLen
;
int32_t
tlen
=
pBlock
->
keyLen
;
if
(
dcol
!=
0
)
{
if
(
dcol
!=
0
)
{
SBlockCol
*
pBlockCol
=
&
(
pBlockData
->
cols
[
ccol
]);
SBlockCol
*
pBlockCol
=
&
(
pBlockData
->
cols
[
ccol
]);
tcolId
=
pBlockCol
->
colId
;
tcolId
=
pBlockCol
->
colId
;
toffset
=
pBlockCol
->
offset
;
toffset
=
tsdbGetBlockColOffset
(
pBlockCol
)
;
tlen
=
pBlockCol
->
len
;
tlen
=
pBlockCol
->
len
;
}
else
{
}
else
{
ASSERT
(
pDataCol
->
colId
==
tcolId
);
ASSERT
(
pDataCol
->
colId
==
tcolId
);
...
@@ -488,7 +488,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
...
@@ -488,7 +488,7 @@ static int tsdbLoadBlockDataImpl(SReadH *pReadh, SBlock *pBlock, SDataCols *pDat
if
(
tsdbCheckAndDecodeColumnData
(
pDataCol
,
POINTER_SHIFT
(
pBlockData
,
tsize
+
toffset
),
tlen
,
pBlock
->
algorithm
,
if
(
tsdbCheckAndDecodeColumnData
(
pDataCol
,
POINTER_SHIFT
(
pBlockData
,
tsize
+
toffset
),
tlen
,
pBlock
->
algorithm
,
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
,
TSDB_READ_COMP_BUF
(
pReadh
),
pBlock
->
numOfRows
,
pDataCols
->
maxPoints
,
TSDB_READ_COMP_BUF
(
pReadh
),
(
int
)
taosTSizeof
(
TSDB_READ_COMP_BUF
(
pReadh
)))
<
0
)
{
(
int
)
taosTSizeof
(
TSDB_READ_COMP_BUF
(
pReadh
)))
<
0
)
{
tsdbError
(
"vgId:%d file %s is broken at column %d block offset %"
PRId64
" column offset %
d
"
,
tsdbError
(
"vgId:%d file %s is broken at column %d block offset %"
PRId64
" column offset %
u
"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tcolId
,
(
int64_t
)
pBlock
->
offset
,
toffset
);
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tcolId
,
(
int64_t
)
pBlock
->
offset
,
toffset
);
return
-
1
;
return
-
1
;
}
}
...
@@ -627,7 +627,7 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
...
@@ -627,7 +627,7 @@ static int tsdbLoadColData(SReadH *pReadh, SDFile *pDFile, SBlock *pBlock, SBloc
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_READ_BUF
(
pReadh
)),
pBlockCol
->
len
)
<
0
)
return
-
1
;
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_READ_BUF
(
pReadh
)),
pBlockCol
->
len
)
<
0
)
return
-
1
;
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_READ_COMP_BUF
(
pReadh
)),
tsize
)
<
0
)
return
-
1
;
if
(
tsdbMakeRoom
((
void
**
)(
&
TSDB_READ_COMP_BUF
(
pReadh
)),
tsize
)
<
0
)
return
-
1
;
int64_t
offset
=
pBlock
->
offset
+
TSDB_BLOCK_STATIS_SIZE
(
pBlock
->
numOfCols
)
+
pBlockCol
->
offset
;
int64_t
offset
=
pBlock
->
offset
+
TSDB_BLOCK_STATIS_SIZE
(
pBlock
->
numOfCols
)
+
tsdbGetBlockColOffset
(
pBlockCol
)
;
if
(
tsdbSeekDFile
(
pDFile
,
offset
,
SEEK_SET
)
<
0
)
{
if
(
tsdbSeekDFile
(
pDFile
,
offset
,
SEEK_SET
)
<
0
)
{
tsdbError
(
"vgId:%d failed to load block column data while seek file %s to offset %"
PRId64
" since %s"
,
tsdbError
(
"vgId:%d failed to load block column data while seek file %s to offset %"
PRId64
" since %s"
,
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
tstrerror
(
terrno
));
TSDB_READ_REPO_ID
(
pReadh
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
tstrerror
(
terrno
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录