Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
99587db7
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看板
提交
99587db7
编写于
4月 14, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: udf handle expired after 10s
上级
fe718f60
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
15 deletion
+17
-15
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+16
-14
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+1
-1
未找到文件。
source/libs/function/src/tudf.c
浏览文件 @
99587db7
...
...
@@ -960,7 +960,7 @@ int32_t udfcOpen();
int32_t
udfcClose
();
int32_t
acquireUdfFuncHandle
(
char
*
udfName
,
UdfcFuncHandle
*
pHandle
);
void
releaseUdfFuncHandle
(
char
*
udfName
);
void
releaseUdfFuncHandle
(
char
*
udfName
,
UdfcFuncHandle
handle
);
int32_t
cleanUpUdfs
();
bool
udfAggGetEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
...
...
@@ -992,11 +992,12 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
uv_mutex_unlock
(
&
gUdfcProxy
.
udfStubsMutex
);
return
0
;
}
else
{
fnInfo
(
"invalid handle for %s, refCount: %d, create time: %"
PRId64
". remove it from cache"
,
udfName
,
fnInfo
(
"
udf
invalid handle for %s, refCount: %d, create time: %"
PRId64
". remove it from cache"
,
udfName
,
foundStub
->
refCount
,
foundStub
->
createTime
);
taosArrayRemove
(
gUdfcProxy
.
udfStubs
,
stubIndex
);
}
}
else
{
fnInfo
(
"udf handle expired for %s, will setup udf. move it to expired list"
,
udfName
);
taosArrayRemove
(
gUdfcProxy
.
udfStubs
,
stubIndex
);
taosArrayPush
(
gUdfcProxy
.
expiredUdfStubs
,
foundStub
);
taosArraySort
(
gUdfcProxy
.
expiredUdfStubs
,
compareUdfcFuncSub
);
...
...
@@ -1020,7 +1021,7 @@ int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) {
return
code
;
}
void
releaseUdfFuncHandle
(
char
*
udfName
)
{
void
releaseUdfFuncHandle
(
char
*
udfName
,
UdfcFuncHandle
handle
)
{
uv_mutex_lock
(
&
gUdfcProxy
.
udfStubsMutex
);
SUdfcFuncStub
key
=
{
0
};
strncpy
(
key
.
udfName
,
udfName
,
TSDB_FUNC_NAME_LEN
);
...
...
@@ -1030,10 +1031,10 @@ void releaseUdfFuncHandle(char *udfName) {
uv_mutex_unlock
(
&
gUdfcProxy
.
udfStubsMutex
);
return
;
}
if
(
foundStub
!=
NULL
&&
foundStub
->
refCount
>
0
)
{
if
(
foundStub
!=
NULL
&&
foundStub
->
handle
==
handle
&&
foundStub
->
refCount
>
0
)
{
--
foundStub
->
refCount
;
}
if
(
expiredStub
!=
NULL
&&
expiredStub
->
refCount
>
0
)
{
if
(
expiredStub
!=
NULL
&&
expiredStub
->
handle
==
handle
&&
expiredStub
->
refCount
>
0
)
{
--
expiredStub
->
refCount
;
}
uv_mutex_unlock
(
&
gUdfcProxy
.
udfStubsMutex
);
...
...
@@ -1046,7 +1047,8 @@ int32_t cleanUpUdfs() {
}
uv_mutex_lock
(
&
gUdfcProxy
.
udfStubsMutex
);
if
(
gUdfcProxy
.
udfStubs
==
NULL
||
taosArrayGetSize
(
gUdfcProxy
.
udfStubs
)
==
0
)
{
if
((
gUdfcProxy
.
udfStubs
==
NULL
||
taosArrayGetSize
(
gUdfcProxy
.
udfStubs
)
==
0
)
&&
(
gUdfcProxy
.
expiredUdfStubs
==
NULL
||
taosArrayGetSize
(
gUdfcProxy
.
expiredUdfStubs
)
==
0
))
{
uv_mutex_unlock
(
&
gUdfcProxy
.
udfStubsMutex
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1092,7 +1094,7 @@ int32_t cleanUpUdfs() {
}
++
i
;
}
taosArrayDestroy
(
gUdfcProxy
.
u
dfStubs
);
taosArrayDestroy
(
gUdfcProxy
.
expiredU
dfStubs
);
gUdfcProxy
.
expiredUdfStubs
=
expiredUdfStubs
;
uv_mutex_unlock
(
&
gUdfcProxy
.
udfStubsMutex
);
return
0
;
...
...
@@ -1109,7 +1111,7 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols,
code
=
doCallUdfScalarFunc
(
handle
,
input
,
numOfCols
,
output
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
fnError
(
"udfc scalar function execution failure"
);
releaseUdfFuncHandle
(
udfName
);
releaseUdfFuncHandle
(
udfName
,
handle
);
return
code
;
}
...
...
@@ -1123,7 +1125,7 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols,
code
=
TSDB_CODE_UDF_INVALID_OUTPUT_TYPE
;
}
}
releaseUdfFuncHandle
(
udfName
);
releaseUdfFuncHandle
(
udfName
,
handle
);
return
code
;
}
...
...
@@ -1156,7 +1158,7 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResult
SUdfInterBuf
buf
=
{
0
};
if
((
udfCode
=
doCallUdfAggInit
(
handle
,
&
buf
))
!=
0
)
{
fnError
(
"udfAggInit error. step doCallUdfAggInit. udf code: %d"
,
udfCode
);
releaseUdfFuncHandle
(
pCtx
->
udfName
);
releaseUdfFuncHandle
(
pCtx
->
udfName
,
handle
);
return
false
;
}
if
(
buf
.
bufLen
<=
session
->
bufSize
)
{
...
...
@@ -1165,10 +1167,10 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResult
udfRes
->
interResNum
=
buf
.
numOfResult
;
}
else
{
fnError
(
"udfc inter buf size %d is greater than function bufSize %d"
,
buf
.
bufLen
,
session
->
bufSize
);
releaseUdfFuncHandle
(
pCtx
->
udfName
);
releaseUdfFuncHandle
(
pCtx
->
udfName
,
handle
);
return
false
;
}
releaseUdfFuncHandle
(
pCtx
->
udfName
);
releaseUdfFuncHandle
(
pCtx
->
udfName
,
handle
);
freeUdfInterBuf
(
&
buf
);
return
true
;
}
...
...
@@ -1225,7 +1227,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
taosArrayDestroy
(
pTempBlock
->
pDataBlock
);
taosMemoryFree
(
pTempBlock
);
releaseUdfFuncHandle
(
pCtx
->
udfName
);
releaseUdfFuncHandle
(
pCtx
->
udfName
,
handle
);
freeUdfInterBuf
(
&
newState
);
return
udfCode
;
}
...
...
@@ -1270,7 +1272,7 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock) {
freeUdfInterBuf
(
&
resultBuf
);
int32_t
numOfResults
=
functionFinalizeWithResultBuf
(
pCtx
,
pBlock
,
udfRes
->
finalResBuf
);
releaseUdfFuncHandle
(
pCtx
->
udfName
);
releaseUdfFuncHandle
(
pCtx
->
udfName
,
handle
);
return
udfCallCode
==
0
?
numOfResults
:
udfCallCode
;
}
...
...
source/libs/function/src/udfd.c
浏览文件 @
99587db7
...
...
@@ -591,7 +591,7 @@ SUdf *udfdNewUdf(const char *udfName) {
SUdf
*
udfdGetOrCreateUdf
(
const
char
*
udfName
)
{
uv_mutex_lock
(
&
global
.
udfsMutex
);
SUdf
**
pUdfHash
=
taosHashGet
(
global
.
udfsHash
,
udfName
,
strlen
(
udfName
));
int64_t
currTime
=
taosGetTimestamp
Sec
();
int64_t
currTime
=
taosGetTimestamp
Ms
();
bool
expired
=
false
;
if
(
pUdfHash
)
{
expired
=
currTime
-
(
*
pUdfHash
)
->
lastFetchTime
>
10
*
1000
;
// 10s
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录