diff --git a/src/client/inc/tscGlobalmerge.h b/src/client/inc/tscGlobalmerge.h index a462d78ff0d0b57cc05bbe3bde273700e426ba4e..875bb5e178d1d0f50b78b4b6c0cf6ae29b884a1a 100644 --- a/src/client/inc/tscGlobalmerge.h +++ b/src/client/inc/tscGlobalmerge.h @@ -58,6 +58,7 @@ typedef struct SRetrieveSupport { int32_t subqueryIndex; // index of current vnode in vnode list struct SSqlObj *pParentSql; tFilePage * localBuffer; // temp buffer, there is a buffer for each vnode to + uint32_t localBufferSize; uint32_t numOfRetry; // record the number of retry times } SRetrieveSupport; diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index 8e579ad2210920c442a4c447c2fed267b658b546..390c2f882b763a39b0401f512aa4d3c21ad108a9 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -2593,6 +2593,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { trs->pOrderDescriptor = pDesc; trs->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage)); + trs->localBufferSize = nBufferSize + sizeof(tFilePage); if (trs->localBuffer == NULL) { tscError("0x%"PRIx64" failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s", pSql->self, i, strerror(errno)); tfree(trs); @@ -2713,8 +2714,10 @@ static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32 memcpy(trsupport, oriTrs, sizeof(*trsupport)); - const uint32_t nBufferSize = (1u << 16u); // 64KB - trsupport->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage)); + // the buffer size should be the same as tscHandleMasterSTableQuery, which was used to initialize the SColumnModel + // the capacity member of SColumnModel will be used to save the trsupport->localBuffer in tscRetrieveFromDnodeCallBack + trsupport->localBuffer = (tFilePage *)calloc(1, oriTrs->localBufferSize); + if (trsupport->localBuffer == NULL) { tscError("0x%"PRIx64" failed to malloc buffer for local buffer, reason:%s", pSql->self, strerror(errno)); tfree(trsupport);