@@ -158,9 +158,14 @@ func (h *batcherHandler) ConsumeClaim(
158158 )
159159
160160 wg := & sync.WaitGroup {}
161- go processor .Process (wg , session , processChan , errChan )
162161 wg .Add (1 )
163- defer wg .Wait ()
162+ go processor .Process (wg , session , processChan , errChan )
163+
164+ defer func () {
165+ klog .V (2 ).Infof ("%s: wg wait() for processing to return" , claim .Topic ())
166+ wg .Wait ()
167+ klog .V (2 ).Infof ("%s: wg done. processing returned" , claim .Topic ())
168+ }()
164169
165170 klog .V (4 ).Infof ("%s: read msgs" , claim .Topic ())
166171 // NOTE:
@@ -204,10 +209,10 @@ func (h *batcherHandler) ConsumeClaim(
204209 // Deserialize the message
205210 msg , err := h .serializer .Deserialize (message )
206211 if err != nil {
207- return fmt .Errorf ("error deserializing binary, err: %s\n " , err )
212+ return fmt .Errorf ("%s: consumeClaim returning, error deserializing binary, err: %s\n " , claim . Topic () , err )
208213 }
209214 if msg == nil || msg .Value == nil {
210- return fmt .Errorf ("got message as nil, message: %+v\n " , msg )
215+ return fmt .Errorf ("%s: consumeClaim returning, error, got message as nil, message: %+v\n " , claim . Topic () , msg )
211216 }
212217
213218 if lastSchemaId == nil {
@@ -220,22 +225,22 @@ func (h *batcherHandler) ConsumeClaim(
220225 msg .SchemaId ,
221226 )
222227 // Flush the batch due to schema change
223- msgBatch .Flush ()
228+ msgBatch .Flush (session . Context () )
224229 }
225230 // Flush the batch by size or insert in batch
226- msgBatch .Insert (msg )
231+ msgBatch .Insert (session . Context (), msg )
227232 * lastSchemaId = msg .SchemaId
228233 case <- maxWaitTicker .C :
229234 // Flush the batch by time
230235 klog .V (2 ).Infof (
231236 "%s: maxWaitSeconds hit" ,
232237 claim .Topic (),
233238 )
234- msgBatch .Flush ()
239+ msgBatch .Flush (session . Context () )
235240 case err := <- errChan :
236241 syscall .Kill (syscall .Getpid (), syscall .SIGINT )
237242 klog .Errorf (
238- "%s: error occured in processing, err: %v, triggered shutdown" ,
243+ "consumeClaim returning, %s: error occured in processing, err: %v, triggered shutdown" ,
239244 claim .Topic (),
240245 err ,
241246 )
0 commit comments