{"record":{"id":"0f6cb5888695a213","repo":"apache/beam","slug":"quantile-trackers-should-not-be-used-in-production-due-to","errorCode":null,"errorMessage":"Quantile trackers should not be used in production due to the unbounded memory consumption.","messagePattern":"Quantile trackers should not be used in production due to the unbounded memory consumption\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/python/apache_beam/ml/anomaly/univariate/quantile.py","lineNumber":192,"sourceCode":"        A list of calculated quantiles.\n    \"\"\"\n    return self._master._get_helper(self._master._sorted_items, self._q)\n\n\n@specifiable\nclass BufferedLandmarkQuantileTracker(BufferedQuantileTracker):\n  \"\"\"Landmark quantile tracker using a sorted list for quantile calculation.\n\n  Warning:\n    Landmark quantile trackers have unbounded memory consumption as they store\n    all pushed values in a sorted list. Avoid using in production for\n    long-running streams.\n\n  Args:\n    q: The quantile to calculate, a float between 0 and 1 (inclusive).\n  \"\"\"\n  def __init__(self, q):\n    warnings.warn(\n        \"Quantile trackers should not be used in production due to \"\n        \"the unbounded memory consumption.\")\n    super().__init__(window_mode=WindowMode.LANDMARK, q=q)\n\n\n@specifiable\nclass BufferedSlidingQuantileTracker(BufferedQuantileTracker):\n  \"\"\"Sliding window quantile tracker using a sorted list for quantile\n  calculation.\n\n  Warning:\n    Maintains a sorted list of values within the sliding window to calculate\n    the specified quantile. Memory consumption is bounded by the window size\n    but can still be significant for large windows.\n\n  Args:\n    window_size: The size of the sliding window.\n    q: The quantile to calculate, a float between 0 and 1 (inclusive).","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/ml/anomaly/univariate/quantile.py#L174-L210","documentation":"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.","triggerScenarios":"`QuantileTracker(q)` (or a specifiable-annotated instantiation in an anomaly detection config) with landmark window mode.","commonSituations":"Prototyping anomaly detection on unbounded production streams where memory grows indefinitely until OOM.","solutions":["Switch to a bounded-memory tracker variant for production.","Restrict QuantileTracker to offline/bounded datasets or short-lived experiments.","Escalate the warning to an error outside experiments: `warnings.filterwarnings('error', message='Quantile trackers should not be used in production')`."],"exampleFix":"// before\ntracker = QuantileTracker(q=0.99)\n// after\ntracker = OrderStatisticsTracker(q=0.99)  # bounded-memory alternative","handlingStrategy":"validation","validationCode":"import warnings\nwith warnings.catch_warnings(record=True) as w:\n    warnings.simplefilter('always')\n    tracker = QuantileTracker(q=0.5)\n    if any('unbounded memory' in str(x.message) for x in w) and is_production:\n        raise ValueError('QuantileTracker is unbounded; not allowed in production')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use bounded-memory tracker variants for long-running streams.","Restrict QuantileTracker to tests and offline analysis.","Filter that escalates this warning to an error outside experiments."],"tags":["python","memory","apache-beam","anomaly-detection"],"backgroundTag":"unbounded-memory-usage","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}