From d5c30f5ea5b2eb487a20aa89bfa3641f6efa3b7c Mon Sep 17 00:00:00 2001 From: slzhou Date: Wed, 18 May 2022 10:29:32 +0800 Subject: [PATCH] fix: release udf func handle when udf agg failure --- source/libs/function/src/tudf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 4322705c13..5c6209dc4d 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -1386,7 +1386,7 @@ int32_t cleanUpUdfs() { if (handle != NULL && ((SUdfcUvSession*)handle)->udfUvPipe != NULL) { taosArrayPush(udfStubs, stub); } else { - fnInfo("invalid handle for %s, refCount: %d, last ref time: %"PRId64". remove it from cache", + fnInfo("udf invalid handle for %s, refCount: %d, last ref time: %"PRId64". remove it from cache", stub->udfName, stub->refCount, stub->lastRefTime); } } @@ -1602,6 +1602,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); return false; } udfRes->interResNum = buf.numOfResult; @@ -1609,6 +1610,7 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResult memcpy(udfRes->interResBuf, buf.buf, buf.bufLen); } else { fnError("udfc inter buf size %d is greater than function bufSize %d", buf.bufLen, session->bufSize); + releaseUdfFuncHandle(pCtx->udfName); return false; } freeUdfInterBuf(&buf); @@ -1674,6 +1676,9 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) { blockDataDestroy(inputBlock); taosArrayDestroy(tempBlock.pDataBlock); + if (udfCode != 0) { + releaseUdfFuncHandle(pCtx->udfName); + } freeUdfInterBuf(&newState); return udfCode; } -- GitLab