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

  1. Check the logged cause for state read failures and fix connectivity to the runner state service.
  2. Increase state read timeouts / retry budgets on the gRPC channel.
  3. If metrics accuracy matters, ensure state-backed iterables are fully consumable (don't abort bundles mid-iteration).
  4. 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

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/a6d0a35555caf8d5. Report an issue: GitHub.