docs(arrow/ipc): document that Writer and FileWriter are not concurrency safe#856
Merged
Merged
Conversation
…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
lidavidm
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Closes #55.
arrow/ipc.Writerandarrow/ipc.FileWriterwrap an arbitraryio.Writerand write to it without any internal synchronization. CallingWrite(orClose) 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.Writercannot 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
WriterandFileWriternow state that they are not safe for concurrent use, explain why (interleaved/duplicated output via an unsynchronizedio.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, andgo vetare clean forarrow/ipc.Are there any user-facing changes?
No API or behavior changes; only added godoc on
ipc.Writerandipc.FileWriter.