apache/beam · error
side input closed
Error message
side input closed
What it means
The harness side-input reader fetches segments from the state manager over a channel. When the buffer is empty and the reader has been closed (r.closed), Read returns this error instead of issuing another state request, since no further data can ever arrive.
Solutions
- Stop iterating the side input when the reader is closed; propagate cancellation from bundle teardown.
- Ensure exec nodes do not outlive their side-input readers (release/cancel readers on teardown).
- If reads can legitimately race with close, guard with a closed check or treat the error as termination.
Defensive patterns
Strategy: try-catch
Validate before calling
if reader.Closed() { return io.EOF /* or stop iteration */ } Type guard
func readable(r *sideInputReader) bool { return r != nil && !r.closed } Try / catch
n, err := reader.Read(ctx, key)
if err != nil && strings.Contains(err.Error(), "side input closed") {
return errStopIteration // bundle is tearing down; stop reading
} Prevention
- Bind side-input iteration to bundle context cancellation
- Never retain side-input readers beyond node/bundle teardown
- Check reader liveness before each segment request in long-running iterations
When it happens
Trigger: Calling Read on a sideInputReader after its Close/cleanup ran, or a Downstream read continuing after the reader was closed due to bundle teardown or an upstream abort.
Common situations: Bundle cancellation mid-iteration of a side input; exec code retaining a side-input reader across node teardown; harness shutdown while a DoFn is still iterating the side input.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- broken stream
- broken stream
- capacity of cache cannot be negative, got
- combine does not support side inputs
- empty port
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/5dd45d55d04ef33a.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/harness/statemgr.go:487
instID: instID,
key: key,
ch: ch,
writeType: writeTypeClear,
}
}
func (r *stateKeyReader) Read(buf []byte) (int, error) {
if r.buf == nil {
if r.eof {
return 0, io.EOF
}
// Buffer empty. Get next segment.
r.mu.Lock()
if r.closed {
r.mu.Unlock()
return 0, errors.New("side input closed")
}
localChannel := r.ch
r.mu.Unlock()
req := &fnpb.StateRequest{
// Id: set by StateChannel
InstructionId: string(r.instID),
StateKey: r.key,
Request: &fnpb.StateRequest_Get{
Get: &fnpb.StateGetRequest{
ContinuationToken: r.token,
},
},
}
resp, err := localChannel.Send(req)
if err != nil {
r.Close()
return 0, errView on GitHub (pinned to 12126d8942)