Skip to content

Commit

Permalink
fix leak
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysan committed Feb 23, 2023
1 parent 5e28565 commit 0c79cc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion executor/analyze_col_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ func (e *AnalyzeColumnsExecV2) subMergeWorker(resultCh chan<- *samplingMergeResu
times := val.(int)
for i := 0; i < times; i++ {
e.memTracker.Consume(5 << 20)
time.Sleep(100 * time.Millisecond)
time.Sleep(10 * time.Millisecond)
}
})
retCollector := statistics.NewRowSampleCollector(int(e.analyzePB.ColReq.SampleSize), e.analyzePB.ColReq.GetSampleRate(), l)
Expand Down
5 changes: 4 additions & 1 deletion executor/analyzetest/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,8 @@ func TestGlobalMemoryControlForAnalyze(t *testing.T) {
_, err := tk0.Exec(sql)
require.NotNil(t, err)
require.True(t, strings.Contains(err.Error(), "Out Of Memory Quota!"))
// sleep to wait all workers to consume memory and exit
time.Sleep(10 * time.Millisecond)
runtime.GC()
}

Expand Down Expand Up @@ -3172,7 +3174,8 @@ func TestGlobalMemoryControlForAutoAnalyze(t *testing.T) {
rs := tk.MustQuery("select fail_reason from mysql.analyze_jobs where table_name=? and state=? limit 1", "t", "failed")
failReason := rs.Rows()[0][0].(string)
require.True(t, strings.Contains(failReason, "Out Of Memory Quota!"))

// sleep to wait all workers to consume memory and exit
time.Sleep(10 * time.Millisecond)
childTrackers = executor.GlobalAnalyzeMemoryTracker.GetChildrenForTest()
require.Len(t, childTrackers, 0)
}

0 comments on commit 0c79cc8

Please sign in to comment.