apache/beam · warning

Quantile trackers should not be used in production due to…

Error message

Quantile trackers should not be used in production due to the unbounded memory consumption.

What it means

Constructing a QuantileTracker emits a warning that it stores all observed values (landmark window mode), causing unbounded memory growth, and must not be used in production. It is intended for experimentation on bounded or short-lived streams.

Solutions

  1. Switch to a bounded-memory tracker variant for production.
  2. Restrict QuantileTracker to offline/bounded datasets or short-lived experiments.
  3. Escalate the warning to an error outside experiments: `warnings.filterwarnings('error', message='Quantile trackers should not be used in production')`.

Example fix

// before
tracker = QuantileTracker(q=0.99)
// after
tracker = OrderStatisticsTracker(q=0.99)  # bounded-memory alternative
Defensive patterns

Strategy: validation

Validate before calling

import warnings
with warnings.catch_warnings(record=True) as w:
    warnings.simplefilter('always')
    tracker = QuantileTracker(q=0.5)
    if any('unbounded memory' in str(x.message) for x in w) and is_production:
        raise ValueError('QuantileTracker is unbounded; not allowed in production')

Prevention

When it happens

Trigger: `QuantileTracker(q)` (or a specifiable-annotated instantiation in an anomaly detection config) with landmark window mode.

Common situations: Prototyping anomaly detection on unbounded production streams where memory grows indefinitely until OOM.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/ml/anomaly/univariate/quantile.py:192

        A list of calculated quantiles.
    """
    return self._master._get_helper(self._master._sorted_items, self._q)


@specifiable
class BufferedLandmarkQuantileTracker(BufferedQuantileTracker):
  """Landmark quantile tracker using a sorted list for quantile calculation.

  Warning:
    Landmark quantile trackers have unbounded memory consumption as they store
    all pushed values in a sorted list. Avoid using in production for
    long-running streams.

  Args:
    q: The quantile to calculate, a float between 0 and 1 (inclusive).
  """
  def __init__(self, q):
    warnings.warn(
        "Quantile trackers should not be used in production due to "
        "the unbounded memory consumption.")
    super().__init__(window_mode=WindowMode.LANDMARK, q=q)


@specifiable
class BufferedSlidingQuantileTracker(BufferedQuantileTracker):
  """Sliding window quantile tracker using a sorted list for quantile
  calculation.

  Warning:
    Maintains a sorted list of values within the sliding window to calculate
    the specified quantile. Memory consumption is bounded by the window size
    but can still be significant for large windows.

  Args:
    window_size: The size of the sliding window.
    q: The quantile to calculate, a float between 0 and 1 (inclusive).

View on GitHub (pinned to 12126d8942)