alberttwong opened a new issue, #1576: URL: https://github.com/apache/arrow-go/issues/1576
### Describe the enhancement requested Could the imported C-stream API expose its existing deterministic release capability in a supported public type, and could its lifetime documentation match the current implementation? An additive typed import helper or explicitly documented public assertion contract would avoid relying on a hidden concrete implementation; this does not require breaking the existing `arrio.Reader` signature. Source inspection at `fc5d5ce5a99b8583448b2cb70d0e9357dd10a420`: - [ImportCRecordReader](https://github.com/apache/arrow-go/blob/fc5d5ce5a99b8583448b2cb70d0e9357dd10a420/arrow/cdata/interface.go#L186-L202) returns `(arrio.Reader, error)`. [arrio.Reader](https://github.com/apache/arrow-go/blob/fc5d5ce5a99b8583448b2cb70d0e9357dd10a420/arrow/arrio/arrio.go#L29) exposes `Read`, but no `Release`/`Close`. - The returned unexported [nativeCRecordBatchReader.Release](https://github.com/apache/arrow-go/blob/fc5d5ce5a99b8583448b2cb70d0e9357dd10a420/arrow/cdata/cdata.go#L1229-L1244) **already** stops cleanup registrations and releases/frees the stream and scratch array when its reference count reaches zero. This is not a report that all stream release waits for GC. - The public import comments still describe `SetFinalizer`-based release, while current initialization uses `runtime.AddCleanup`, and [importAllocator.Free](https://github.com/apache/arrow-go/blob/fc5d5ce5a99b8583448b2cb70d0e9357dd10a420/arrow/cdata/import_allocator.go#L49-L64) also has explicit last-buffer release behavior. Please distinguish the explicit reference-counted contract from fallback cleanup. Our generated ADBC binding currently obtains the returned `arrio.Reader` and asserts it to `array.RecordReader` when passing it to BindStream: [downstream call site](https://github.com/redis/redis-adbc-driver/blob/987b5db1debf34c25440124fc51e4a28e5fbbb97/go/pkg/driver.go#L1713-L1718). Making this a supported typed contract would reduce glue/type assertions and help us prove lifetime behavior without a private cdata fork. ### Requested documentation and tests - State which public interface callers should use for explicit stream release, exactly which references they own, and when C stream versus retained-batch/buffer callbacks can run. - Cover normal exhaustion, release before first read, early/error release, retained batches/buffers after reader release, nested/dictionary/zero-buffer values, and balanced callbacks/handles. Verify explicit cleanup without relying on a forced GC to make the test pass, while preserving fallback cleanup as appropriate. - Preserve a retained batch's valid lifetime; do not release its foreign buffers early simply because the stream was released. - If an existing public API already provides the supported typed contract, an example and corrected docs would be preferable to another API. ### Context and boundaries Driverbase's separate generated-bridge GC policy request is https://github.com/adbc-drivers/driverbase-go/issues/243; downstream ownership/integration work is https://github.com/redis/redis-adbc-driver/issues/446. Our [native diagnostics](https://github.com/redis/redis-adbc-driver/blob/987b5db1debf34c25440124fc51e4a28e5fbbb97/benchmarks/crud-execution/results/diagnostics/README.md) measure roughly 0.4–0.5 ms for previous-result close, but that span is not pure GC time, an Arrow Go regression, or proof that changing this API improves end-to-end latency. Our earlier GC experiment did not improve complete native bulk reads. This request is for a clear supported ownership contract and reduced downstream glue, not a request to remove GC or a reproduced leak. No new runtime tests or benchmark runs were performed to file this issue. ### Component(s) Integration, Documentation -- 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]
