@@ -71,25 +71,16 @@ type HashAggPartialWorker struct {
71
71
inflightChunkSync * sync.WaitGroup
72
72
}
73
73
74
- func (w * HashAggPartialWorker ) getChildInput () bool {
74
+ func (w * HashAggPartialWorker ) getChildInput () ( * chunk. Chunk , bool ) {
75
75
select {
76
76
case <- w .finishCh :
77
- return false
77
+ return nil , false
78
78
case chk , ok := <- w .inputCh :
79
79
if ! ok {
80
- return false
81
- }
82
-
83
- sizeBefore := w .chk .MemoryUsage ()
84
- w .chk .SwapColumns (chk )
85
- w .memTracker .Consume (w .chk .MemoryUsage () - sizeBefore )
86
-
87
- w .giveBackCh <- & HashAggInput {
88
- chk : chk ,
89
- giveBackCh : w .inputCh ,
80
+ return nil , false
90
81
}
82
+ return chk , true
91
83
}
92
- return true
93
84
}
94
85
95
86
func (w * HashAggPartialWorker ) fetchChunkAndProcess (ctx sessionctx.Context , hasError * bool , needShuffle * bool ) bool {
@@ -99,14 +90,24 @@ func (w *HashAggPartialWorker) fetchChunkAndProcess(ctx sessionctx.Context, hasE
99
90
}
100
91
101
92
waitStart := time .Now ()
102
- ok := w .getChildInput ()
103
- updateWaitTime (w .stats , waitStart )
104
-
93
+ chk , ok := w .getChildInput ()
105
94
if ! ok {
106
95
return false
107
96
}
108
97
109
98
defer w .inflightChunkSync .Done ()
99
+ updateWaitTime (w .stats , waitStart )
100
+
101
+ w .intestDuringPartialWorkerRun ()
102
+
103
+ sizeBefore := w .chk .MemoryUsage ()
104
+ w .chk .SwapColumns (chk )
105
+ w .memTracker .Consume (w .chk .MemoryUsage () - sizeBefore )
106
+
107
+ w .giveBackCh <- & HashAggInput {
108
+ chk : chk ,
109
+ giveBackCh : w .inputCh ,
110
+ }
110
111
111
112
execStart := time .Now ()
112
113
if err := w .updatePartialResult (ctx , w .chk , len (w .partialResultsMap )); err != nil {
0 commit comments