diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 1e95380096..b77b21b03f 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2209,10 +2209,10 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) // restore user defined fp pParentObj->fp = pParentObj->fetchFp; int32_t numOfSub = pParentObj->subState.numOfSub; + doFreeInsertSupporter(pParentObj); if (pParentObj->res.code == TSDB_CODE_SUCCESS) { tscDebug("%p Async insertion completed, total inserted:%d", pParentObj, pParentObj->res.numOfRows); - doFreeInsertSupporter(pParentObj); // todo remove this parameter in async callback function definition. // all data has been sent to vnode, call user function @@ -2220,7 +2220,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) (*pParentObj->fp)(pParentObj->param, pParentObj, v); } else { if (!needRetryInsert(pParentObj, numOfSub)) { - doFreeInsertSupporter(pParentObj); tscQueueAsyncRes(pParentObj); return; } @@ -2263,7 +2262,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows) if (code != TSDB_CODE_SUCCESS) { pParentObj->res.code = code; - doFreeInsertSupporter(pParentObj); tscQueueAsyncRes(pParentObj); return; } @@ -2303,7 +2301,11 @@ int32_t tscHandleMultivnodeInsert(SSqlObj *pSql) { if (pSql->pSubs != NULL) { for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) { SSqlObj* pSub = pSql->pSubs[i]; + SInsertSupporter* pSup = calloc(1, sizeof(SInsertSupporter)); + pSup->index = i; + pSup->pSql = pSql; + pSub->param = pSup; tscDebug("%p sub:%p launch sub insert, orderOfSub:%d", pSql, pSub, i); if (pSub->res.code != TSDB_CODE_SUCCESS) { tscHandleInsertRetry(pSql, pSub); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 35ae9e4d4c..7dfab427b5 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -2589,6 +2589,8 @@ void tscSVgroupInfoCopy(SVgroupInfo* dst, const SVgroupInfo* src) { for(int32_t i = 0; i < dst->numOfEps; ++i) { tfree(dst->epAddr[i].fqdn); dst->epAddr[i].port = src->epAddr[i].port; + assert(dst->epAddr[i].fqdn == NULL); + dst->epAddr[i].fqdn = strdup(src->epAddr[i].fqdn); } }