AynSiddiqui opened a new pull request, #1643:
URL: https://github.com/apache/arrow-go/pull/1643

   ### Rationale for this change
   
   Fixes #1642.
   
   Follow-ups noted on #1609, from the C Device Data Interface spec:
   
   - After `cancel` the consumer stopped reading `taskQueue`, so tasks the 
producer still sent were never passed to `extract_data`. The spec says a 
consumer that doesn't want a task must still call `extract_data` (with `NULL`) 
so the producer can clean up, and that more `on_next_task` calls can follow 
`cancel`. When the queue filled up, `on_next_task` also blocked.
   - `asyncTaskExtract` released the record but never deleted the task's 
`cgo.Handle` or freed its heap slot, so every extracted task leaked both.
   
   ### What changes are included in this PR?
   
   - `asyncTaskQueue` keeps draining `taskQueue` after it returns, calling 
`extract_data` with `NULL` for each task until `release` closes the queue. This 
runs after the record stream is closed, so consumers of the stream are not 
delayed.
   - `asyncTaskExtract` deletes the task's `cgo.Handle` and frees its slot once 
it has been used (including the `NULL` case).
   
   ### Are these changes tested?
   
   Yes. `TestAsyncDrainTasksAfterCancel` runs a producer that sends more tasks 
than the queue holds after `cancel` and checks each is extracted with `NULL`. 
`TestAsyncTaskExtractNull` now checks the handle is deleted. Both fail on main 
and pass here. `go test -race -count=20 -run TestAsync ./arrow/cdata` and the 
`arrow/cdata` suite under `-asan` pass.
   
   ### Are there any user-facing changes?
   
   No.
   
   Notes:
   - `extract_data` must still be called exactly once per task. A second call 
is now a use-after-free.
   - Tasks still buffered when `release` returns may be extracted with `NULL` 
afterwards, as the main loop already did.
   - If the consumer cancels and stops reading `Stream`, the loop can still 
block on `recordStream <- ...` and never reach the drain. That is pre-existing 
and out of scope here.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to