bezineb5 opened a new issue, #1629:
URL: https://github.com/apache/arrow-go/issues/1629

   ## Describe the bug
   
   v18.9.0 introduced process-global `sync.Pool` caching of zstd encoders and 
decoders in `arrow/ipc/compression.go` (`zstdDecompressorPool`, 
`zstdEncoderPools`). Previously (<= v18.8.0), each reader/writer constructed 
its own `zstd.NewReader(nil)` / `zstd.NewWriter(nil)` instance.
   
   A `zstd.Decoder` internally allocates its decoding pool as a channel 
(`d.decoders = make(chan *blockDec, ...)`) at construction time. With 
`testing/synctest` bubbles (stable since Go 1.25), a decoder constructed inside 
one bubble gets Put back into the process-global pool and can be borrowed by 
any goroutine in the process. Receiving on that channel afterwards crosses the 
bubble boundary, and the runtime aborts:
   
   ```
   fatal error: receive on synctest channel from outside bubble
   
   goroutine 27 [running]:
   github.com/klauspost/compress/zstd.(*Decoder).DecodeAll(...)
        .../github.com/klauspost/[email protected]/zstd/decoder.go:360 +0x70
   github.com/apache/arrow-go/v18/arrow/ipc.(*zstdDecompressor).Decompress(...)
        .../github.com/apache/arrow-go/[email protected]/arrow/ipc/compression.go:166 
+0x50
   github.com/apache/arrow-go/v18/arrow/ipc.(*ipcSource).buffer(...)
        .../github.com/apache/arrow-go/[email protected]/arrow/ipc/file_reader.go:605 
+0x328
   github.com/apache/arrow-go/v18/arrow/ipc.(*Reader).Next(...)
        .../github.com/apache/arrow-go/[email protected]/arrow/ipc/reader.go:218
   github.com/apache/arrow-go/v18/arrow/ipc.(*Reader).read(...)
   &lt;user test helper spawning a reader goroutine&gt;
   ```
   
   This makes any test suite that:
   1. reads or writes zstd-compressed Arrow IPC data inside a `synctest.Test` 
bubble, and
   2. also reads/writes compressed Arrow IPC outside a bubble (or in a second 
bubble)
   
   abort the whole test binary with a fatal runtime error. It reproduced 100% 
of the time in our case (hundreds of runs across CI and local). We pinned back 
to v18.8.0, which constructs per-instance codecs and has no such conflict.
   
   ## To Reproduce
   
   Minimal reproduction sketch:
   
   ```go
   func TestZstdArrowInSynctest(t *testing.T) {
        // create + consume a zstd-compressed IPC file OUTSIDE a bubble
        writeAndReadZstdArrow(t, "a.arrow")
   
        synctest.Test(t, func(t *testing.T) {
                // the same process-global pooled Decoder is borrowed in here;
                // its d.decoders channel was created outside the bubble
                writeAndReadZstdArrow(t, "b.arrow") // fatal error here
        })
   }
   ```
   
   In our case the order was: earlier plain subtests exercised compressed IPC 
readback, then a `synctest.Test` subtest borrowed the pooled decoder. The 
inverse order (decoder created in-bubble, borrowed outside) is equally fatal — 
both directions cross the bubble boundary through the unconfined global pool.
   
   Expected: compressed IPC I/O works inside a bubble the same as outside, as 
it did in <= v18.8.0. Observed: fatal runtime error crashing the entire test 
process.
   
   ## Component
   Go — `arrow/ipc` (compression codecs)
   
   ## Version
   - arrow-go v18.9.0 (regression; v18.8.0 is unaffected)
   - Go 1.27.4, darwin/arm64
   - klauspost/compress v1.20.4 (via arrow-go's own go.mod requirement)


-- 
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