Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
09e1aeaa
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看板
未验证
提交
09e1aeaa
编写于
1月 07, 2021
作者:
H
haojun Liao
提交者:
GitHub
1月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4845 from taosdata/hotfix/TD-2673
[TD-2673]<fix>:some tmp files are left in server's tmp directory
上级
3202b932
e2fc62e3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
25 deletion
+41
-25
src/query/inc/qTsbuf.h
src/query/inc/qTsbuf.h
+1
-0
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+3
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+24
-19
src/query/src/qTsbuf.c
src/query/src/qTsbuf.c
+13
-5
未找到文件。
src/query/inc/qTsbuf.h
浏览文件 @
09e1aeaa
...
...
@@ -88,6 +88,7 @@ typedef struct STSBuf {
STSList
tsData
;
// uncompressed raw ts data
uint64_t
numOfTotal
;
bool
autoDelete
;
bool
remainOpen
;
int32_t
tsOrder
;
// order of timestamp in ts comp buffer
STSCursor
cur
;
}
STSBuf
;
...
...
src/query/src/qAggMain.c
浏览文件 @
09e1aeaa
...
...
@@ -3836,8 +3836,10 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
STSBuf
*
pTSbuf
=
pInfo
->
pTSBuf
;
tsBufFlush
(
pTSbuf
);
strcpy
(
pCtx
->
aOutputBuf
,
pTSbuf
->
path
);
*
(
FILE
**
)
pCtx
->
aOutputBuf
=
pTSbuf
->
f
;
pTSbuf
->
remainOpen
=
true
;
tsBufDestroy
(
pTSbuf
);
doFinalizer
(
pCtx
);
}
...
...
src/query/src/qExecutor.c
浏览文件 @
09e1aeaa
...
...
@@ -2010,6 +2010,7 @@ static void doFreeQueryHandle(SQInfo* pQInfo) {
assert
(
pMemRef
->
ref
==
0
&&
pMemRef
->
imem
==
NULL
&&
pMemRef
->
mem
==
NULL
);
}
static
void
teardownQueryRuntimeEnv
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
if
(
pRuntimeEnv
->
pQuery
==
NULL
)
{
return
;
...
...
@@ -2021,6 +2022,16 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
qDebug
(
"QInfo:%p teardown runtime env"
,
pQInfo
);
cleanupResultRowInfo
(
&
pRuntimeEnv
->
windowResInfo
);
if
(
isTSCompQuery
(
pQuery
))
{
FILE
*
f
=
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
;
if
(
f
)
{
fclose
(
f
);
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
=
NULL
;
}
}
if
(
pRuntimeEnv
->
pCtx
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
...
...
@@ -6949,10 +6960,10 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
* TODO handle the case that the file is too large to send back one time
*/
if
(
isTSCompQuery
(
pQuery
)
&&
(
*
numOfRows
)
>
0
)
{
struct
stat
f
s
tat
;
if
(
stat
(
pQuery
->
sdata
[
0
]
->
data
,
&
fs
tat
)
==
0
)
{
*
numOfRows
=
f
s
tat
.
st_size
;
return
f
s
tat
.
st_size
;
struct
stat
f
S
tat
;
if
(
fstat
(
fileno
(
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
),
&
fS
tat
)
==
0
)
{
*
numOfRows
=
f
S
tat
.
st_size
;
return
f
S
tat
.
st_size
;
}
else
{
qError
(
"QInfo:%p failed to get file info, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
return
0
;
...
...
@@ -6968,15 +6979,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// load data from file to msg buffer
if
(
isTSCompQuery
(
pQuery
))
{
int32_t
fd
=
open
(
pQuery
->
sdata
[
0
]
->
data
,
O_RDONLY
,
0666
);
FILE
*
f
=
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
;
// make sure file exist
if
(
FD_VALID
(
fd
)
)
{
uint64_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
if
(
f
)
{
off_t
s
=
lseek
(
fileno
(
f
)
,
0
,
SEEK_END
);
qDebug
(
"QInfo:%p ts comp data return, file:%
s, size:%"
PRId64
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
s
);
if
(
lseek
(
fd
,
0
,
SEEK_SET
)
>=
0
)
{
size_t
sz
=
read
(
fd
,
data
,
(
uint32_t
)
s
);
qDebug
(
"QInfo:%p ts comp data return, file:%
p, size:%"
PRId64
,
pQInfo
,
f
,
s
);
if
(
fseek
(
f
,
0
,
SEEK_SET
)
>=
0
)
{
size_t
sz
=
fread
(
data
,
1
,
s
,
f
);
if
(
sz
<
s
)
{
// todo handle error
assert
(
0
);
}
...
...
@@ -6984,15 +6996,8 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
UNUSED
(
s
);
}
close
(
fd
);
unlink
(
pQuery
->
sdata
[
0
]
->
data
);
}
else
{
// todo return the error code to client and handle invalid fd
qError
(
"QInfo:%p failed to open tmp file to send ts-comp data to client, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
if
(
fd
!=
-
1
)
{
close
(
fd
);
}
fclose
(
f
);
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
=
NULL
;
}
// all data returned, set query over
...
...
src/query/src/qTsbuf.c
浏览文件 @
09e1aeaa
...
...
@@ -19,6 +19,8 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
if
(
pTSBuf
==
NULL
)
{
return
NULL
;
}
pTSBuf
->
autoDelete
=
autoDelete
;
taosGetTmpfilePath
(
"join"
,
pTSBuf
->
path
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"w+"
);
...
...
@@ -26,6 +28,10 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
free
(
pTSBuf
);
return
NULL
;
}
if
(
!
autoDelete
)
{
unlink
(
pTSBuf
->
path
);
}
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
return
NULL
;
...
...
@@ -37,8 +43,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
tsBufResetPos
(
pTSBuf
);
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
autoDelete
=
autoDelete
;
pTSBuf
->
tsOrder
=
order
;
return
pTSBuf
;
...
...
@@ -49,6 +54,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
if
(
pTSBuf
==
NULL
)
{
return
NULL
;
}
pTSBuf
->
autoDelete
=
autoDelete
;
tstrncpy
(
pTSBuf
->
path
,
path
,
sizeof
(
pTSBuf
->
path
));
...
...
@@ -129,7 +136,6 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
// ascending by default
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
autoDelete
=
autoDelete
;
// tscDebug("create tsBuf from file:%s, fd:%d, size:%d, numOfGroups:%d, autoDelete:%d", pTSBuf->path, fileno(pTSBuf->f),
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
...
...
@@ -147,8 +153,10 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
tfree
(
pTSBuf
->
pData
);
tfree
(
pTSBuf
->
block
.
payload
);
fclose
(
pTSBuf
->
f
);
if
(
!
pTSBuf
->
remainOpen
)
{
fclose
(
pTSBuf
->
f
);
}
if
(
pTSBuf
->
autoDelete
)
{
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录