Skip to content

Commit 29cc3ea

Browse files
authored
fix: memory leak while taos_query blocked then terminal signal received (#35064)
1 parent ec53c59 commit 29cc3ea

5 files changed

Lines changed: 14 additions & 8 deletions

File tree

source/client/src/clientImpl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ int32_t asyncExecDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
513513
SMsgSendInfo* pSendMsg = buildMsgInfoImpl(pRequest);
514514

515515
int32_t code = asyncSendMsgToServer(pAppInfo->pTransporter, &pMsgInfo->epSet, NULL, pSendMsg);
516+
// pMsgInfo->pMsg has been transferred to pRequest->body.requestMsg and pMsgInfo->epSet has
517+
// been consumed by asyncSendMsgToServer; the SCmdMsgInfo struct itself is no longer needed.
518+
// Free it now so that nodesDestroyAllocatorSet() during atexit does not orphan it when the
519+
// chunk containing pQuery is released before doDestroyRequest() can be called.
520+
taosMemoryFreeClear(pQuery->pCmdMsg);
516521
if (code) {
517522
doRequestCallback(pRequest, code);
518523
}

source/libs/executor/src/sysscanoperator.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,7 +4935,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
49354935
pRsp->numOfRows, pInfo->loadInfo.totalRows);
49364936

49374937
if (pRsp->numOfRows == 0) {
4938-
taosMemoryFree(pRsp);
4938+
taosMemoryFreeClear(pInfo->pRsp);
49394939
return NULL;
49404940
}
49414941
}
@@ -4945,7 +4945,7 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
49454945
if (code != TSDB_CODE_SUCCESS) {
49464946
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
49474947
pTaskInfo->code = code;
4948-
taosMemoryFreeClear(pRsp);
4948+
taosMemoryFreeClear(pInfo->pRsp);
49494949
T_LONG_JMP(pTaskInfo->env, code);
49504950
}
49514951
updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator);
@@ -4954,10 +4954,10 @@ static SSDataBlock* sysTableScanFromMNode(SOperatorInfo* pOperator, SSysTableSca
49544954
if (code != TSDB_CODE_SUCCESS) {
49554955
qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code));
49564956
pTaskInfo->code = code;
4957-
taosMemoryFreeClear(pRsp);
4957+
taosMemoryFreeClear(pInfo->pRsp);
49584958
T_LONG_JMP(pTaskInfo->env, code);
49594959
}
4960-
taosMemoryFree(pRsp);
4960+
taosMemoryFreeClear(pInfo->pRsp);
49614961
if (pInfo->pRes->info.rows > 0) {
49624962
return pInfo->pRes;
49634963
} else if (pOperator->status == OP_EXEC_DONE) {

test/cases/18-StreamProcessing/20-UseCase/test_idmp_meters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ def trigger_stream5(self):
644644
# blank 12
645645
disTs += 12 * step
646646

647+
time.sleep(5)
647648
# disorder write 1 rows
648649
count = 2
649650
vals = "39,200,200"

test/cases/25-Privileges/test_priv_control.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def revoke_role(self, role_name, user_name):
162162

163163
def exec_sql(self, sql):
164164
# Execute SQL and return success
165-
tdSql.execute(sql)
165+
tdSql.execute(sql, queryTimes=30)
166166
print(f" Executed: {sql}")
167167

168168
def exec_sql_failed(self, sql, errno=None, queryTimes=30):

test/ci/run_upgrade_compat.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ function download_version() {
9696
local start_time
9797
start_time=$(date +%s)
9898

99-
# Quick check: skip if cache exists and all files are >= 30M
99+
# Quick check: skip if cache exists and all files are >= 10M
100100
local file_count valid_count
101101
file_count=$(find "$target_dir" -maxdepth 1 -type f 2>/dev/null | wc -l)
102-
valid_count=$(find "$target_dir" -maxdepth 1 -type f -size +30M 2>/dev/null | wc -l)
102+
valid_count=$(find "$target_dir" -maxdepth 1 -type f -size +10M 2>/dev/null | wc -l)
103103
if [ "$file_count" -ge 2 ] && [ "$valid_count" -eq "$file_count" ]; then
104104
return 0
105105
fi
@@ -110,7 +110,7 @@ function download_version() {
110110

111111
# Re-check inside lock in case another process already finished
112112
file_count=$(find "$target_dir" -maxdepth 1 -type f 2>/dev/null | wc -l)
113-
valid_count=$(find "$target_dir" -maxdepth 1 -type f -size +30M 2>/dev/null | wc -l)
113+
valid_count=$(find "$target_dir" -maxdepth 1 -type f -size +10M 2>/dev/null | wc -l)
114114
if [ "$file_count" -ge 2 ] && [ "$valid_count" -eq "$file_count" ]; then
115115
return 0
116116
fi

0 commit comments

Comments
 (0)