Skip to content

Commit

Permalink
[fix] : fix missing free for compile.Scope (matrixorigin#17932)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensenojs authored Aug 7, 2024
1 parent 9293eee commit 36ef943
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/sql/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,7 @@ func (c *Compile) newMergeRemoteScopeByCN(ss []*Scope) []*Scope {
}

func (c *Compile) newBroadcastJoinScopeList(probeScopes []*Scope, buildScopes []*Scope, n *plan.Node) []*Scope {
usedBuildScope := false
rs := c.newMergeRemoteScopeByCN(probeScopes)
for i := range rs {
rs[i].IsJoin = true
Expand All @@ -3591,11 +3592,13 @@ func (c *Compile) newBroadcastJoinScopeList(probeScopes []*Scope, buildScopes []
// so we set it to false now
if c.IsTpQuery() {
rs[0].PreScopes = append(rs[0].PreScopes, buildScopes[0])
usedBuildScope = true
} else {
c.anal.isFirst = false
for i := range rs {
if isSameCN(rs[i].NodeInfo.Addr, c.addr) {
mergeBuild := buildScopes[0]
usedBuildScope = true
if len(buildScopes) > 1 {
mergeBuild = c.newMergeScope(buildScopes)
}
Expand All @@ -3607,6 +3610,12 @@ func (c *Compile) newBroadcastJoinScopeList(probeScopes []*Scope, buildScopes []
}
}

if !usedBuildScope {
for _, s := range buildScopes {
s.release()
}
}

return rs
}

Expand Down

0 comments on commit 36ef943

Please sign in to comment.