Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] : free the memory of stmt holded by ComputationWrapper manually #13646

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pkg/frontend/computation_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ func (cwft *TxnComputationWrapper) GetAst() tree.Statement {
return cwft.stmt
}

func (cwft *TxnComputationWrapper) Free() {
cwft.plan = nil
cwft.proc = nil
cwft.ses = nil
cwft.compile = nil
cwft.runResult = nil
cwft.stmt = nil
}

func (cwft *TxnComputationWrapper) GetProcess() *process.Process {
return cwft.proc
}
Expand Down
13 changes: 8 additions & 5 deletions pkg/frontend/mysql_cmd_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3923,11 +3923,14 @@ func (mce *MysqlCmdExecutor) doComQuery(requestCtx context.Context, input *UserI
plans := make([]*plan.Plan, len(cws))
stmts := make([]tree.Statement, len(cws))
for i, cw := range cws {
if cwft, ok := cw.(*TxnComputationWrapper); ok && checkNodeCanCache(cwft.plan) {
plans[i] = cwft.plan
stmts[i] = cwft.stmt
} else {
return nil
if cwft, ok := cw.(*TxnComputationWrapper); ok {
if checkNodeCanCache(cwft.plan) {
plans[i] = cwft.plan
stmts[i] = cwft.stmt
} else {
cwft.Free()
return nil
}
}
}
ses.cachePlan(input.getSql(), stmts, plans)
Expand Down
Loading