Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21d57a36
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看板
提交
21d57a36
编写于
1月 22, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): check for failure during add new buf pages.
上级
ba092ced
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
51 deletion
+57
-51
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+9
-1
source/util/src/tpagedbuf.c
source/util/src/tpagedbuf.c
+48
-50
未找到文件。
source/libs/executor/src/groupoperator.c
浏览文件 @
21d57a36
...
@@ -593,8 +593,11 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
...
@@ -593,8 +593,11 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
int32_t
pageId
=
0
;
int32_t
pageId
=
0
;
pPage
=
getNewBufPage
(
pInfo
->
pBuf
,
&
pageId
);
pPage
=
getNewBufPage
(
pInfo
->
pBuf
,
&
pageId
);
taosArrayPush
(
p
->
pPageList
,
&
pageId
);
if
(
pPage
==
NULL
)
{
return
pPage
;
}
taosArrayPush
(
p
->
pPageList
,
&
pageId
);
*
(
int32_t
*
)
pPage
=
0
;
*
(
int32_t
*
)
pPage
=
0
;
}
else
{
}
else
{
int32_t
*
curId
=
taosArrayGetLast
(
p
->
pPageList
);
int32_t
*
curId
=
taosArrayGetLast
(
p
->
pPageList
);
...
@@ -612,6 +615,11 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
...
@@ -612,6 +615,11 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
// add a new page for current group
// add a new page for current group
int32_t
pageId
=
0
;
int32_t
pageId
=
0
;
pPage
=
getNewBufPage
(
pInfo
->
pBuf
,
&
pageId
);
pPage
=
getNewBufPage
(
pInfo
->
pBuf
,
&
pageId
);
if
(
pPage
==
NULL
)
{
qError
(
"failed to get new buffer, code:%s"
,
tstrerror
(
terrno
));
return
NULL
;
}
taosArrayPush
(
p
->
pPageList
,
&
pageId
);
taosArrayPush
(
p
->
pPageList
,
&
pageId
);
memset
(
pPage
,
0
,
getBufPageSize
(
pInfo
->
pBuf
));
memset
(
pPage
,
0
,
getBufPageSize
(
pInfo
->
pBuf
));
}
}
...
...
source/util/src/tpagedbuf.c
浏览文件 @
21d57a36
...
@@ -222,7 +222,6 @@ static char* flushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) {
...
@@ -222,7 +222,6 @@ static char* flushPageToDisk(SDiskbasedBuf* pBuf, SPageInfo* pg) {
char
*
p
=
doFlushPageToDisk
(
pBuf
,
pg
);
char
*
p
=
doFlushPageToDisk
(
pBuf
,
pg
);
setPageNotInBuf
(
pg
);
setPageNotInBuf
(
pg
);
pg
->
dirty
=
false
;
pg
->
dirty
=
false
;
return
p
;
return
p
;
}
}
...
@@ -286,32 +285,21 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) {
...
@@ -286,32 +285,21 @@ static SListNode* getEldestUnrefedPage(SDiskbasedBuf* pBuf) {
}
}
static
char
*
evacOneDataPage
(
SDiskbasedBuf
*
pBuf
)
{
static
char
*
evacOneDataPage
(
SDiskbasedBuf
*
pBuf
)
{
char
*
bufPage
=
NULL
;
SListNode
*
pn
=
getEldestUnrefedPage
(
pBuf
);
SListNode
*
pn
=
getEldestUnrefedPage
(
pBuf
);
terrno
=
0
;
if
(
pn
==
NULL
)
{
// no available buffer pages now, return.
return
NULL
;
// all pages are referenced by user, try to allocate new space
}
if
(
pn
==
NULL
)
{
int32_t
prev
=
pBuf
->
inMemPages
;
// increase by 50% of previous mem pages
pBuf
->
inMemPages
=
(
int32_t
)(
pBuf
->
inMemPages
*
1
.
5
f
);
// qWarn("%p in memory buf page not sufficient, expand from %d to %d, page size:%d", pBuf, prev,
// pBuf->inMemPages, pBuf->pageSize);
}
else
{
tdListPopNode
(
pBuf
->
lruList
,
pn
);
SPageInfo
*
d
=
*
(
SPageInfo
**
)
pn
->
data
;
terrno
=
0
;
ASSERTS
(
d
->
pn
==
pn
,
"d->pn not equal pn"
);
tdListPopNode
(
pBuf
->
lruList
,
pn
);
d
->
pn
=
NULL
;
SPageInfo
*
d
=
*
(
SPageInfo
**
)
pn
->
data
;
taosMemoryFreeClear
(
pn
);
ASSERTS
(
d
->
pn
==
pn
,
"d->pn not equal pn"
);
bufPage
=
flushPageToDisk
(
pBuf
,
d
)
;
d
->
pn
=
NULL
;
}
taosMemoryFreeClear
(
pn
);
return
bufPage
;
return
flushPageToDisk
(
pBuf
,
d
)
;
}
}
static
void
lruListPushFront
(
SList
*
pList
,
SPageInfo
*
pi
)
{
static
void
lruListPushFront
(
SList
*
pList
,
SPageInfo
*
pi
)
{
...
@@ -338,7 +326,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
...
@@ -338,7 +326,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
SDiskbasedBuf
*
pPBuf
=
*
pBuf
;
SDiskbasedBuf
*
pPBuf
=
*
pBuf
;
if
(
pPBuf
==
NULL
)
{
if
(
pPBuf
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
goto
_error
;
}
}
pPBuf
->
pageSize
=
pagesize
;
pPBuf
->
pageSize
=
pagesize
;
...
@@ -362,24 +350,50 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
...
@@ -362,24 +350,50 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
pPBuf
->
pIdList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pPBuf
->
pIdList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pPBuf
->
assistBuf
=
taosMemoryMalloc
(
pPBuf
->
pageSize
+
2
);
// EXTRA BYTES
pPBuf
->
assistBuf
=
taosMemoryMalloc
(
pPBuf
->
pageSize
+
2
);
// EXTRA BYTES
if
(
pPBuf
->
assistBuf
==
NULL
)
{
goto
_error
;
}
pPBuf
->
all
=
taosHashInit
(
10
,
fn
,
true
,
false
);
pPBuf
->
all
=
taosHashInit
(
10
,
fn
,
true
,
false
);
pPBuf
->
prefix
=
(
char
*
)
dir
;
if
(
pPBuf
->
all
==
NULL
)
{
goto
_error
;
}
pPBuf
->
prefix
=
(
char
*
)
dir
;
pPBuf
->
emptyDummyIdList
=
taosArrayInit
(
1
,
sizeof
(
int32_t
));
pPBuf
->
emptyDummyIdList
=
taosArrayInit
(
1
,
sizeof
(
int32_t
));
// qDebug("QInfo:0x%"PRIx64" create resBuf for output, page size:%d, inmem buf pages:%d, file:%s", qId,
// qDebug("QInfo:0x%"PRIx64" create resBuf for output, page size:%d, inmem buf pages:%d, file:%s", qId,
// pPBuf->pageSize,
// pPBuf->pageSize, pPBuf->inMemPages, pPBuf->path);
// pPBuf->inMemPages, pPBuf->path);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_error:
destroyDiskbasedBuf
(
pPBuf
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
void
*
getNewBufPage
(
SDiskbasedBuf
*
pBuf
,
int32_t
*
pageId
)
{
static
char
*
doExtractPage
(
SDiskbasedBuf
*
pBuf
)
{
pBuf
->
statis
.
getPages
+=
1
;
char
*
availablePage
=
NULL
;
char
*
availablePage
=
NULL
;
if
(
NO_IN_MEM_AVAILABLE_PAGES
(
pBuf
))
{
if
(
NO_IN_MEM_AVAILABLE_PAGES
(
pBuf
))
{
availablePage
=
evacOneDataPage
(
pBuf
);
availablePage
=
evacOneDataPage
(
pBuf
);
if
(
availablePage
==
NULL
)
{
uWarn
(
"no available buf pages, current:%d, max:%d"
,
listNEles
(
pBuf
->
lruList
),
pBuf
->
inMemPages
)
}
}
else
{
availablePage
=
taosMemoryCalloc
(
1
,
getAllocPageSize
(
pBuf
->
pageSize
));
// add extract bytes in case of zipped buffer increased.
if
(
availablePage
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
availablePage
;
}
void
*
getNewBufPage
(
SDiskbasedBuf
*
pBuf
,
int32_t
*
pageId
)
{
pBuf
->
statis
.
getPages
+=
1
;
char
*
availablePage
=
doExtractPage
(
pBuf
);
if
(
availablePage
==
NULL
)
{
return
NULL
;
}
}
SPageInfo
*
pi
=
NULL
;
SPageInfo
*
pi
=
NULL
;
...
@@ -402,16 +416,8 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) {
...
@@ -402,16 +416,8 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) {
}
}
// add to LRU list
// add to LRU list
ASSERT
(
listNEles
(
pBuf
->
lruList
)
<
pBuf
->
inMemPages
&&
pBuf
->
inMemPages
>
0
);
lruListPushFront
(
pBuf
->
lruList
,
pi
);
lruListPushFront
(
pBuf
->
lruList
,
pi
);
pi
->
pData
=
availablePage
;
// allocate buf
if
(
availablePage
==
NULL
)
{
pi
->
pData
=
taosMemoryCalloc
(
1
,
getAllocPageSize
(
pBuf
->
pageSize
));
// add extract bytes in case of zipped buffer increased.
}
else
{
pi
->
pData
=
availablePage
;
}
((
void
**
)
pi
->
pData
)[
0
]
=
pi
;
((
void
**
)
pi
->
pData
)[
0
]
=
pi
;
#ifdef BUF_PAGE_DEBUG
#ifdef BUF_PAGE_DEBUG
...
@@ -447,18 +453,9 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
...
@@ -447,18 +453,9 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
ASSERT
((
*
pi
)
->
pData
==
NULL
&&
(
*
pi
)
->
pn
==
NULL
&&
ASSERT
((
*
pi
)
->
pData
==
NULL
&&
(
*
pi
)
->
pn
==
NULL
&&
(((
*
pi
)
->
length
>=
0
&&
(
*
pi
)
->
offset
>=
0
)
||
((
*
pi
)
->
length
==
-
1
&&
(
*
pi
)
->
offset
==
-
1
)));
(((
*
pi
)
->
length
>=
0
&&
(
*
pi
)
->
offset
>=
0
)
||
((
*
pi
)
->
length
==
-
1
&&
(
*
pi
)
->
offset
==
-
1
)));
char
*
availablePage
=
NULL
;
(
*
pi
)
->
pData
=
doExtractPage
(
pBuf
);
if
(
NO_IN_MEM_AVAILABLE_PAGES
(
pBuf
))
{
if
((
*
pi
)
->
pData
==
NULL
)
{
availablePage
=
evacOneDataPage
(
pBuf
);
return
NULL
;
if
(
availablePage
==
NULL
)
{
return
NULL
;
}
}
if
(
availablePage
==
NULL
)
{
(
*
pi
)
->
pData
=
taosMemoryCalloc
(
1
,
getAllocPageSize
(
pBuf
->
pageSize
));
}
else
{
(
*
pi
)
->
pData
=
availablePage
;
}
}
// set the ptr to the new SPageInfo
// set the ptr to the new SPageInfo
...
@@ -471,6 +468,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
...
@@ -471,6 +468,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
if
((
*
pi
)
->
length
>
0
&&
(
*
pi
)
->
offset
>=
0
)
{
if
((
*
pi
)
->
length
>
0
&&
(
*
pi
)
->
offset
>=
0
)
{
int32_t
code
=
loadPageFromDisk
(
pBuf
,
*
pi
);
int32_t
code
=
loadPageFromDisk
(
pBuf
,
*
pi
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
terrno
=
code
;
return
NULL
;
return
NULL
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录