Skip to content

Commit

Permalink
[fix] : free all member of TxnComputationWrapper manually (#13783)
Browse files Browse the repository at this point in the history
cherry-pick from : #13646

Approved by: @daviszhen, @qingxinhome, @sukki37
  • Loading branch information
jensenojs authored Dec 26, 2023
1 parent c193191 commit 25dae92
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
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 @@ -3906,11 +3906,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

0 comments on commit 25dae92

Please sign in to comment.