From 2b9ac078497ef227ef2ef19ad8a4aa33f59cb0a3 Mon Sep 17 00:00:00 2001 From: shenglian zhou Date: Fri, 3 Sep 2021 10:47:43 +0800 Subject: [PATCH] [TD-6511]:reissue subquery with same buffersize of the original subquery --- src/client/inc/tscGlobalmerge.h | 1 + src/client/src/tscSubquery.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/inc/tscGlobalmerge.h b/src/client/inc/tscGlobalmerge.h index a462d78ff0..875bb5e178 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 8e579ad221..390c2f882b 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); -- GitLab