Skip to content

docs(arrow/ipc): document that Writer and FileWriter are not concurrency safe#856

Merged
zeroshade merged 1 commit into
apache:mainfrom
zeroshade:docs/ipc-writer-concurrency
Jun 18, 2026
Merged

docs(arrow/ipc): document that Writer and FileWriter are not concurrency safe#856
zeroshade merged 1 commit into
apache:mainfrom
zeroshade:docs/ipc-writer-concurrency

Conversation

@zeroshade

Copy link
Copy Markdown
Member

Rationale for this change

Closes #55.

arrow/ipc.Writer and arrow/ipc.FileWriter wrap an arbitrary io.Writer and write to it without any internal synchronization. Calling Write (or Close) concurrently from multiple goroutines therefore races on both the underlying sink and the writer's own state, which can interleave output and corrupt the IPC stream — for example writing the schema header more than once, as reported in #55.

Because an arbitrary io.Writer cannot be assumed to be safe for concurrent use, the writer cannot make this safe on the caller's behalf. The expectation that callers serialize writes was simply undocumented.

What changes are included in this PR?

Documentation only. The type doc comments on Writer and FileWriter now state that they are not safe for concurrent use, explain why (interleaved/duplicated output via an unsynchronized io.Writer), and direct callers that produce records from multiple goroutines to serialize writes themselves — for example by funneling records through a channel to a single goroutine that owns the writer.

No code or behavior changes.

Are these changes tested?

No tests are needed — this is a documentation-only change. gofmt, go build, and go vet are clean for arrow/ipc.

Are there any user-facing changes?

No API or behavior changes; only added godoc on ipc.Writer and ipc.FileWriter.

…ncy safe

The IPC Writer and FileWriter wrap an arbitrary io.Writer and write to it without synchronization, so concurrent Write/Close calls can interleave output and corrupt the stream (for example emitting the schema header more than once). Document on both types that they are not safe for concurrent use and that callers must serialize writes themselves, e.g. by funneling records through a channel to a single owning goroutine.

Closes apache#55
@zeroshade zeroshade requested a review from lidavidm June 18, 2026 22:27
@zeroshade zeroshade merged commit 3979556 into apache:main Jun 18, 2026
25 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] ipc writer is not concurrency safe

2 participants