dataloader icon indicating copy to clipboard operation
dataloader copied to clipboard

wrong time to call 'TraceBatchFinishFunc'

Open jimyang112 opened this issue 5 years ago • 2 comments

ctx, finish := b.tracer.TraceBatch(originalContext, keys)
defer finish(items) // this should be moved

func() {
	defer func() {
		if r := recover(); r != nil {
			panicErr = r
			if b.silent {
				return
			}
			const size = 64 << 10
			buf := make([]byte, size)
			buf = buf[:runtime.Stack(buf, false)]
			log.Printf("Dataloader: Panic received in batch function:: %v\n%s", panicErr, buf)
		}
	}()
	items = b.batchFn(ctx, keys)
}()

// defer finish(items) 

jimyang112 avatar Dec 01 '19 06:12 jimyang112

I just noticed this too. By calling it here, it captures the wrong items slice, so the finish function from the tracing always gets an empty slice.

mjm avatar Jan 27 '20 04:01 mjm

PRs are open :)

nicksrandall avatar Jan 15 '21 17:01 nicksrandall