{"record":{"id":"bc55f038d5dca9c5","repo":"apache/druid","slug":"monitor-doesn-t-support-working-with-lazy-loading","errorCode":null,"errorMessage":"Monitor doesn't support working with lazy loading on start","messagePattern":"Monitor doesn't support working with lazy loading on start","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/server/metrics/SegmentStatsMonitor.java","lineNumber":70,"sourceCode":"  /**\n   * Constructor for this monitor. Will throw IllegalStateException if lazy load on start is set to true.\n   *\n   * @param serverConfig\n   * @param segmentLoadDropHandler\n   * @param segmentLoaderConfig\n   */\n  @Inject\n  public SegmentStatsMonitor(\n      DruidServerConfig serverConfig,\n      SegmentLoadDropHandler segmentLoadDropHandler,\n      SegmentLoaderConfig segmentLoaderConfig\n  )\n  {\n    if (segmentLoaderConfig.isLazyLoadOnStart()) {\n      // log message ensures there is an error displayed at startup if this fails as the exception isn't logged.\n      log.error(\"Monitor doesn't support working with lazy loading on start\");\n      // throw this exception it kill the process at startup\n      throw new IllegalStateException(\"Monitor doesn't support working with lazy loading on start\");\n    }\n    this.serverConfig = serverConfig;\n    this.segmentLoadDropHandler = segmentLoadDropHandler;\n\n  }\n\n  @Override\n  public boolean doMonitor(ServiceEmitter emitter)\n  {\n    for (Map.Entry<String, Long> entry : segmentLoadDropHandler.getAverageNumOfRowsPerSegmentForDatasource().entrySet()) {\n      String dataSource = entry.getKey();\n      long averageSize = entry.getValue();\n      final ServiceMetricEvent.Builder builder = new ServiceMetricEvent.Builder()\n          .setDimension(DruidMetrics.DATASOURCE, dataSource)\n          .setDimension(\"tier\", serverConfig.getTier())\n          .setDimension(\"priority\", String.valueOf(serverConfig.getPriority()));\n      emitter.emit(builder.setMetric(\"segment/rowCount/avg\", averageSize));\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/server/metrics/SegmentStatsMonitor.java#L52-L88","documentation":"SegmentStatsMonitor's constructor throws IllegalStateException if the segment loader config enables lazyLoadOnStart. The monitor needs segments loaded eagerly at startup to report segment statistics and does not support deferred loading, so Druid fails fast (killing the process at startup) rather than running the monitor with missing data.","triggerScenarios":"Configuring a SegmentStatsMonitor in druid.monitoring.monitors together with druid.segmentCache.lazyLoadOnStart=true on a historical node.","commonSituations":"Enabling lazy loading to speed historical startup while keeping the default SegmentStatsMonitor in the monitors list; config templates combining monitoring and lazy-load settings written independently.","solutions":["Remove SegmentStatsMonitor from druid.monitoring.monitors when lazyLoadOnStart=true","Set druid.segmentCache.lazyLoadOnStart=false if segment stats monitoring is required","Replace SegmentStatsMonitor with a monitor compatible with lazy loading","Document the incompatibility in your cluster config templates to prevent recurrence"],"exampleFix":"// before\ndruid.monitoring.monitors=[\"org.apache.druid.server.metrics.SegmentStatsMonitor\"]\ndruid.segmentCache.lazyLoadOnStart=true\n// after\ndruid.monitoring.monitors=[]\ndruid.segmentCache.lazyLoadOnStart=true","handlingStrategy":"validation","validationCode":"boolean isBadCombo = monitors.contains(\"SegmentStatsMonitor\") && Boolean.parseBoolean(props.getProperty(\"druid.segmentCache.lazyLoadOnStart\"));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check monitor/loader-config compatibility before enabling lazy load on historicals","Keep a documented matrix of which monitors work with lazy loading","Start historicals in CI with your monitor set to catch startup failures before deploy","Remove SegmentStatsMonitor when switching a node to lazy loading"],"tags":["config","monitoring"],"backgroundTag":"conflicting-config-options","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}