From 596764479f6d7aebf83d90b22da78916fd719993 Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 7 Apr 2023 10:30:36 +0800 Subject: [PATCH] fix: no more fetch when it is already fetching --- source/libs/catalog/test/catalogTests.cpp | 5 ++++- source/libs/function/src/udfd.c | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 5e543384ac..f3f7d62acf 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -672,12 +672,15 @@ void ctgTestRspUdfInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pR SRetrieveFuncRsp funcRsp = {0}; funcRsp.numOfFuncs = 1; funcRsp.pFuncInfos = taosArrayInit(1, sizeof(SFuncInfo)); + funcRsp.pFuncVersions = taosArrayInit(1, sizeof(int32_t)); SFuncInfo funcInfo = {0}; strcpy(funcInfo.name, "func1"); funcInfo.funcType = ctgTestFuncType; (void)taosArrayPush(funcRsp.pFuncInfos, &funcInfo); - + int32_t version = 0; + (void)taosArrayPush(funcRsp.pFuncVersions, &version); + int32_t rspLen = tSerializeSRetrieveFuncRsp(NULL, 0, &funcRsp); void *pReq = rpcMallocCont(rspLen); tSerializeSRetrieveFuncRsp(pReq, rspLen, &funcRsp); diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 3e03e1acb6..fbf523ac4f 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -581,6 +581,7 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) { SUdf *udfdNewUdf(const char *udfName) { SUdf *udfNew = taosMemoryCalloc(1, sizeof(SUdf)); udfNew->refCount = 1; + udfNew->lastFetchTime = taosGetTimestampUs(); strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN); udfNew->state = UDF_STATE_INIT; @@ -618,6 +619,7 @@ SUdf *udfdGetOrCreateUdf(const char *udfName) { } SUdf *udf = udfdNewUdf(udfName); + SUdf **pUdf = &udf; taosHashPut(global.udfsHash, udfName, strlen(udfName), pUdf, POINTER_BYTES); uv_mutex_unlock(&global.udfsMutex); @@ -902,8 +904,8 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { udf->version = *(int32_t *)taosArrayGet(retrieveRsp.pFuncVersions, 0); msgInfo->code = udfdSaveFuncBodyToFile(pFuncInfo, udf); - if (msgInfo->code == 0) { - udf->lastFetchTime = taosGetTimestampUs(); + if (msgInfo->code != 0) { + udf->lastFetchTime = 0; } tFreeSFuncInfo(pFuncInfo); taosArrayDestroy(retrieveRsp.pFuncInfos); -- GitLab