Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5f89fe76
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看板
提交
5f89fe76
编写于
2月 07, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query):add check for no disk error.
上级
2d951c16
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
46 deletion
+50
-46
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+14
-7
source/util/src/tpagedbuf.c
source/util/src/tpagedbuf.c
+36
-39
未找到文件。
source/libs/executor/src/tsort.c
浏览文件 @
5f89fe76
...
...
@@ -190,8 +190,9 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
qError
(
"Add to buf failed since %s"
,
terrstr
(
terrno
));
return
terrno
;
}
int32_t
code
=
createDiskbasedBuf
(
&
pHandle
->
pBuf
,
pHandle
->
pageSize
,
pHandle
->
numOfPages
*
pHandle
->
pageSize
,
"
doAddTo
Buf"
,
tsTempDir
);
"
sortExternal
Buf"
,
tsTempDir
);
dBufSetPrintInfo
(
pHandle
->
pBuf
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -635,6 +636,7 @@ int32_t getProperSortPageSize(size_t rowSize, uint32_t numOfCols) {
static
int32_t
createInitialSources
(
SSortHandle
*
pHandle
)
{
size_t
sortBufSize
=
pHandle
->
numOfPages
*
pHandle
->
pageSize
;
int32_t
code
=
0
;
if
(
pHandle
->
type
==
SORT_SINGLESOURCE_SORT
)
{
SSortSource
**
pSource
=
taosArrayGet
(
pHandle
->
pOrderedSource
,
0
);
...
...
@@ -663,8 +665,8 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
pHandle
->
beforeFp
(
pBlock
,
pHandle
->
param
);
}
int32_t
code
=
blockDataMerge
(
pHandle
->
pDataBlock
,
pBlock
);
if
(
code
!=
0
)
{
code
=
blockDataMerge
(
pHandle
->
pDataBlock
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
source
->
param
&&
!
source
->
onlyRef
)
{
taosMemoryFree
(
source
->
param
);
}
...
...
@@ -689,6 +691,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
blockDataDestroy
(
source
->
src
.
pBlock
);
source
->
src
.
pBlock
=
NULL
;
}
taosMemoryFree
(
source
);
return
code
;
}
...
...
@@ -696,13 +699,17 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
int64_t
el
=
taosGetTimestampUs
()
-
p
;
pHandle
->
sortElapsed
+=
el
;
doAddToBuf
(
pHandle
->
pDataBlock
,
pHandle
);
code
=
doAddToBuf
(
pHandle
->
pDataBlock
,
pHandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
}
}
if
(
source
->
param
&&
!
source
->
onlyRef
)
{
taosMemoryFree
(
source
->
param
);
}
taosMemoryFree
(
source
);
if
(
pHandle
->
pDataBlock
!=
NULL
&&
pHandle
->
pDataBlock
->
info
.
rows
>
0
)
{
...
...
@@ -711,7 +718,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
// Perform the in-memory sort and then flush data in the buffer into disk.
int64_t
p
=
taosGetTimestampUs
();
int32_t
code
=
blockDataSort
(
pHandle
->
pDataBlock
,
pHandle
->
pSortInfo
);
code
=
blockDataSort
(
pHandle
->
pDataBlock
,
pHandle
->
pSortInfo
);
if
(
code
!=
0
)
{
return
code
;
}
...
...
@@ -729,12 +736,12 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
pHandle
->
tupleHandle
.
pBlock
=
pHandle
->
pDataBlock
;
return
0
;
}
else
{
doAddToBuf
(
pHandle
->
pDataBlock
,
pHandle
);
code
=
doAddToBuf
(
pHandle
->
pDataBlock
,
pHandle
);
}
}
}
return
TSDB_CODE_SUCCESS
;
return
code
;
}
int32_t
tsortOpen
(
SSortHandle
*
pHandle
)
{
...
...
source/util/src/tpagedbuf.c
浏览文件 @
5f89fe76
...
...
@@ -126,6 +126,30 @@ static uint64_t allocateNewPositionInFile(SDiskbasedBuf* pBuf, size_t size) {
static
FORCE_INLINE
size_t
getAllocPageSize
(
int32_t
pageSize
)
{
return
pageSize
+
POINTER_BYTES
+
sizeof
(
SFilePage
);
}
static
int32_t
doFlushBufPageImpl
(
SDiskbasedBuf
*
pBuf
,
int64_t
offset
,
const
char
*
pData
,
int32_t
size
)
{
int32_t
ret
=
taosLSeekFile
(
pBuf
->
pFile
,
offset
,
SEEK_SET
);
if
(
ret
==
-
1
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
terrno
;
}
ret
=
(
int32_t
)
taosWriteFile
(
pBuf
->
pFile
,
pData
,
size
);
if
(
ret
!=
size
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
terrno
;
}
// extend the file
if
(
pBuf
->
fileSize
<
offset
+
size
)
{
pBuf
->
fileSize
=
offset
+
size
;
}
pBuf
->
statis
.
flushBytes
+=
size
;
pBuf
->
statis
.
flushPages
+=
1
;
return
TSDB_CODE_SUCCESS
;
}
static
char
*
doFlushBufPage
(
SDiskbasedBuf
*
pBuf
,
SPageInfo
*
pg
)
{
if
(
pg
->
pData
==
NULL
||
pg
->
used
)
{
uError
(
"invalid params in paged buffer process when flushing buf to disk, %s"
,
pBuf
->
id
);
...
...
@@ -134,7 +158,9 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
}
int32_t
size
=
pBuf
->
pageSize
;
char
*
t
=
NULL
;
int64_t
offset
=
pg
->
offset
;
char
*
t
=
NULL
;
if
((
!
HAS_DATA_IN_DISK
(
pg
))
||
pg
->
dirty
)
{
void
*
payload
=
GET_PAYLOAD_DATA
(
pg
);
t
=
doCompressData
(
payload
,
pBuf
->
pageSize
,
&
size
,
pBuf
);
...
...
@@ -147,59 +173,29 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
// this page is flushed to disk for the first time
if
(
pg
->
dirty
)
{
if
(
!
HAS_DATA_IN_DISK
(
pg
))
{
pg
->
offset
=
allocateNewPositionInFile
(
pBuf
,
size
);
offset
=
allocateNewPositionInFile
(
pBuf
,
size
);
pBuf
->
nextPos
+=
size
;
int32_t
ret
=
taosLSeekFile
(
pBuf
->
pFile
,
pg
->
offset
,
SEEK_SET
);
if
(
ret
==
-
1
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
int32_t
code
=
doFlushBufPageImpl
(
pBuf
,
offset
,
t
,
size
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
ret
=
(
int32_t
)
taosWriteFile
(
pBuf
->
pFile
,
t
,
size
);
if
(
ret
!=
size
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
// extend the file size
if
(
pBuf
->
fileSize
<
pg
->
offset
+
size
)
{
pBuf
->
fileSize
=
pg
->
offset
+
size
;
}
pBuf
->
statis
.
flushBytes
+=
size
;
pBuf
->
statis
.
flushPages
+=
1
;
}
else
{
// length becomes greater, current space is not enough, allocate new place, otherwise, do nothing
if
(
pg
->
length
<
size
)
{
// 1. add current space to free list
SPageDiskInfo
dinfo
=
{.
length
=
pg
->
length
,
.
offset
=
pg
->
offset
};
SPageDiskInfo
dinfo
=
{.
length
=
pg
->
length
,
.
offset
=
offset
};
taosArrayPush
(
pBuf
->
pFree
,
&
dinfo
);
// 2. allocate new position, and update the info
pg
->
offset
=
allocateNewPositionInFile
(
pBuf
,
size
);
offset
=
allocateNewPositionInFile
(
pBuf
,
size
);
pBuf
->
nextPos
+=
size
;
}
// 3. write to disk.
int32_t
ret
=
taosLSeekFile
(
pBuf
->
pFile
,
pg
->
offset
,
SEEK_SET
);
if
(
ret
==
-
1
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
int32_t
code
=
doFlushBufPageImpl
(
pBuf
,
offset
,
t
,
size
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
ret
=
(
int32_t
)
taosWriteFile
(
pBuf
->
pFile
,
t
,
size
);
if
(
ret
!=
size
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
NULL
;
}
if
(
pBuf
->
fileSize
<
pg
->
offset
+
size
)
{
pBuf
->
fileSize
=
pg
->
offset
+
size
;
}
pBuf
->
statis
.
flushBytes
+=
size
;
pBuf
->
statis
.
flushPages
+=
1
;
}
}
else
{
// NOTE: the size may be -1, the this recycle page has not been flushed to disk yet.
size
=
pg
->
length
;
...
...
@@ -209,9 +205,10 @@ static char* doFlushBufPage(SDiskbasedBuf* pBuf, SPageInfo* pg) {
memset
(
pDataBuf
,
0
,
getAllocPageSize
(
pBuf
->
pageSize
));
#ifdef BUF_PAGE_DEBUG
uDebug
(
"page_flush %p, pageId:%d, offset:%d"
,
pDataBuf
,
pg
->
pageId
,
pg
->
offset
);
uDebug
(
"page_flush %p, pageId:%d, offset:%d"
,
pDataBuf
,
pg
->
pageId
,
offset
);
#endif
pg
->
offset
=
offset
;
pg
->
length
=
size
;
// on disk size
return
pDataBuf
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录