Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
09e1aeaa
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
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 {
...
@@ -88,6 +88,7 @@ typedef struct STSBuf {
STSList
tsData
;
// uncompressed raw ts data
STSList
tsData
;
// uncompressed raw ts data
uint64_t
numOfTotal
;
uint64_t
numOfTotal
;
bool
autoDelete
;
bool
autoDelete
;
bool
remainOpen
;
int32_t
tsOrder
;
// order of timestamp in ts comp buffer
int32_t
tsOrder
;
// order of timestamp in ts comp buffer
STSCursor
cur
;
STSCursor
cur
;
}
STSBuf
;
}
STSBuf
;
...
...
src/query/src/qAggMain.c
浏览文件 @
09e1aeaa
...
@@ -3836,8 +3836,10 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
...
@@ -3836,8 +3836,10 @@ static void ts_comp_finalize(SQLFunctionCtx *pCtx) {
STSBuf
*
pTSbuf
=
pInfo
->
pTSBuf
;
STSBuf
*
pTSbuf
=
pInfo
->
pTSBuf
;
tsBufFlush
(
pTSbuf
);
tsBufFlush
(
pTSbuf
);
strcpy
(
pCtx
->
aOutputBuf
,
pTSbuf
->
path
);
*
(
FILE
**
)
pCtx
->
aOutputBuf
=
pTSbuf
->
f
;
pTSbuf
->
remainOpen
=
true
;
tsBufDestroy
(
pTSbuf
);
tsBufDestroy
(
pTSbuf
);
doFinalizer
(
pCtx
);
doFinalizer
(
pCtx
);
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
09e1aeaa
...
@@ -2010,6 +2010,7 @@ static void doFreeQueryHandle(SQInfo* pQInfo) {
...
@@ -2010,6 +2010,7 @@ static void doFreeQueryHandle(SQInfo* pQInfo) {
assert
(
pMemRef
->
ref
==
0
&&
pMemRef
->
imem
==
NULL
&&
pMemRef
->
mem
==
NULL
);
assert
(
pMemRef
->
ref
==
0
&&
pMemRef
->
imem
==
NULL
&&
pMemRef
->
mem
==
NULL
);
}
}
static
void
teardownQueryRuntimeEnv
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
static
void
teardownQueryRuntimeEnv
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
if
(
pRuntimeEnv
->
pQuery
==
NULL
)
{
if
(
pRuntimeEnv
->
pQuery
==
NULL
)
{
return
;
return
;
...
@@ -2021,6 +2022,16 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
...
@@ -2021,6 +2022,16 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
qDebug
(
"QInfo:%p teardown runtime env"
,
pQInfo
);
qDebug
(
"QInfo:%p teardown runtime env"
,
pQInfo
);
cleanupResultRowInfo
(
&
pRuntimeEnv
->
windowResInfo
);
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
)
{
if
(
pRuntimeEnv
->
pCtx
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pQuery
->
numOfOutput
;
++
i
)
{
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
SQLFunctionCtx
*
pCtx
=
&
pRuntimeEnv
->
pCtx
[
i
];
...
@@ -6949,10 +6960,10 @@ static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
...
@@ -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
* TODO handle the case that the file is too large to send back one time
*/
*/
if
(
isTSCompQuery
(
pQuery
)
&&
(
*
numOfRows
)
>
0
)
{
if
(
isTSCompQuery
(
pQuery
)
&&
(
*
numOfRows
)
>
0
)
{
struct
stat
f
s
tat
;
struct
stat
f
S
tat
;
if
(
stat
(
pQuery
->
sdata
[
0
]
->
data
,
&
fs
tat
)
==
0
)
{
if
(
fstat
(
fileno
(
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
),
&
fS
tat
)
==
0
)
{
*
numOfRows
=
f
s
tat
.
st_size
;
*
numOfRows
=
f
S
tat
.
st_size
;
return
f
s
tat
.
st_size
;
return
f
S
tat
.
st_size
;
}
else
{
}
else
{
qError
(
"QInfo:%p failed to get file info, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
qError
(
"QInfo:%p failed to get file info, path:%s, reason:%s"
,
pQInfo
,
pQuery
->
sdata
[
0
]
->
data
,
strerror
(
errno
));
return
0
;
return
0
;
...
@@ -6968,15 +6979,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
...
@@ -6968,15 +6979,16 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
// load data from file to msg buffer
// load data from file to msg buffer
if
(
isTSCompQuery
(
pQuery
))
{
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
// make sure file exist
if
(
FD_VALID
(
fd
)
)
{
if
(
f
)
{
uint64_t
s
=
lseek
(
fd
,
0
,
SEEK_END
);
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
);
qDebug
(
"QInfo:%p ts comp data return, file:%
p, size:%"
PRId64
,
pQInfo
,
f
,
s
);
if
(
lseek
(
fd
,
0
,
SEEK_SET
)
>=
0
)
{
if
(
fseek
(
f
,
0
,
SEEK_SET
)
>=
0
)
{
size_t
sz
=
read
(
fd
,
data
,
(
uint32_t
)
s
);
size_t
sz
=
fread
(
data
,
1
,
s
,
f
);
if
(
sz
<
s
)
{
// todo handle error
if
(
sz
<
s
)
{
// todo handle error
assert
(
0
);
assert
(
0
);
}
}
...
@@ -6984,15 +6996,8 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
...
@@ -6984,15 +6996,8 @@ static int32_t doDumpQueryResult(SQInfo *pQInfo, char *data) {
UNUSED
(
s
);
UNUSED
(
s
);
}
}
close
(
fd
);
fclose
(
f
);
unlink
(
pQuery
->
sdata
[
0
]
->
data
);
*
(
FILE
**
)
pQuery
->
sdata
[
0
]
->
data
=
NULL
;
}
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
);
}
}
}
// all data returned, set query over
// all data returned, set query over
...
...
src/query/src/qTsbuf.c
浏览文件 @
09e1aeaa
...
@@ -19,6 +19,8 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -19,6 +19,8 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
if
(
pTSBuf
==
NULL
)
{
if
(
pTSBuf
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pTSBuf
->
autoDelete
=
autoDelete
;
taosGetTmpfilePath
(
"join"
,
pTSBuf
->
path
);
taosGetTmpfilePath
(
"join"
,
pTSBuf
->
path
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"w+"
);
pTSBuf
->
f
=
fopen
(
pTSBuf
->
path
,
"w+"
);
...
@@ -26,6 +28,10 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -26,6 +28,10 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
free
(
pTSBuf
);
free
(
pTSBuf
);
return
NULL
;
return
NULL
;
}
}
if
(
!
autoDelete
)
{
unlink
(
pTSBuf
->
path
);
}
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
return
NULL
;
return
NULL
;
...
@@ -37,8 +43,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -37,8 +43,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
tsBufResetPos
(
pTSBuf
);
tsBufResetPos
(
pTSBuf
);
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
pTSBuf
->
autoDelete
=
autoDelete
;
pTSBuf
->
tsOrder
=
order
;
pTSBuf
->
tsOrder
=
order
;
return
pTSBuf
;
return
pTSBuf
;
...
@@ -49,6 +54,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -49,6 +54,8 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
if
(
pTSBuf
==
NULL
)
{
if
(
pTSBuf
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pTSBuf
->
autoDelete
=
autoDelete
;
tstrncpy
(
pTSBuf
->
path
,
path
,
sizeof
(
pTSBuf
->
path
));
tstrncpy
(
pTSBuf
->
path
,
path
,
sizeof
(
pTSBuf
->
path
));
...
@@ -129,7 +136,6 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
...
@@ -129,7 +136,6 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) {
// ascending by default
// ascending by default
pTSBuf
->
cur
.
order
=
TSDB_ORDER_ASC
;
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),
// 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);
// pTSBuf->fileSize, pTSBuf->numOfGroups, pTSBuf->autoDelete);
...
@@ -147,8 +153,10 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
...
@@ -147,8 +153,10 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
tfree
(
pTSBuf
->
pData
);
tfree
(
pTSBuf
->
pData
);
tfree
(
pTSBuf
->
block
.
payload
);
tfree
(
pTSBuf
->
block
.
payload
);
fclose
(
pTSBuf
->
f
);
if
(
!
pTSBuf
->
remainOpen
)
{
fclose
(
pTSBuf
->
f
);
}
if
(
pTSBuf
->
autoDelete
)
{
if
(
pTSBuf
->
autoDelete
)
{
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
// ("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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录