apache/beam · warning
Lazily observed byte size will be under reported due to exce
Error message
Lazily observed byte size will be under reported due to exception
What it means
StateBackedIterable.next() advances the underlying state-backed observer to lazily materialize elements and estimate byte size; if advancing throws, the value is still returned but the lazily observed byte size is skipped and this warning is logged once. Data is not lost — only the size accounting is under reported.
Source
Thrown at sdks/java/harness/src/main/java/org/apache/beam/fn/harness/state/StateBackedIterable.java:176
try {
boolean cheap = elementCoder.isRegisterByteSizeObserverCheap(value);
if (cheap || sampleElement()) {
observerProxy.setScalingFactor(
cheap ? 1.0 : Math.max(samplingToken, SAMPLING_CUTOFF) / (double) SAMPLING_CUTOFF);
elementCoder.registerByteSizeObserver(value, observerProxy);
if (observerProxy.getIsLazy()) {
// The observer will only be notified of bytes as the result
// is used. We defer advancing the observer until hasNext in an
// attempt to capture those bytes.
observerNeedsAdvance = true;
} else {
observerNeedsAdvance = false;
observerProxy.advance();
}
}
} catch (Exception e) {
if (!exceptionLogged) {
LOG.warn("Lazily observed byte size will be under reported due to exception", e);
exceptionLogged = true;
}
}
return value;
}
@Override
public void remove() {
super.remove();
}
}
@Override
protected ElementByteSizeObservableIterator<T> createIterator() {
return WrappedObservingIterator.create(
PrefetchableIterators.concat(prefix.iterator(), suffix.iterator()), elemCoder);
}
View on GitHub (pinned to 12126d8942)
Solutions
- Check the logged cause for state read failures and fix connectivity to the runner state service.
- Increase state read timeouts / retry budgets on the gRPC channel.
- If metrics accuracy matters, ensure state-backed iterables are fully consumable (don't abort bundles mid-iteration).
- Verify the runner didn't garbage-collect or invalidate the state token backing the iterable.
Defensive patterns
Strategy: try-catch
Try / catch
try {
observerProxy.advance();
} catch (Exception e) {
if (!exceptionLogged) { LOG.warn("Lazily observed byte size will be under reported", e); exceptionLogged = true; }
} Prevention
- Keep the harness-runner state channel healthy (timeouts, retries)
- Avoid aborting bundles mid-iteration over state-backed iterables
- Confirm state tokens aren't expiring during long iterations
- Accept minor size-metric inaccuracy when this warning is rare
When it happens
Trigger: The state read call (observer advance) against the runner/state service throws (network error, state not found, cancelled stream) while lazily measuring element byte size during iteration.
Common situations: Unstable connection between harness and runner state service; iterables backed by state that expire or become unavailable; high-volume pipelines relying on byte-size accounting for autoscaling metrics.
Related errors
- Unable to infer a coder for ValueState and no Coder was spec
- Unable to infer a coder for CombiningState and no Coder was
- Unable to infer a coder for CombiningWithContextState and no
- Unable to infer a coder for BagState and no Coder was specif
- Unable to infer a coder for OrderedListState and no Coder wa
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/a6d0a35555caf8d5.
Report an issue: GitHub.