{"record":{"id":"049fd2d2a5d827f3","repo":"apache/hadoop","slug":"router-quota-manager-is-not-initialized","errorCode":null,"errorMessage":"Router quota manager is not initialized.","messagePattern":"Router quota manager is not initialized\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUpdateService.java","lineNumber":68,"sourceCode":"public class RouterQuotaUpdateService extends PeriodicService {\n  private static final Logger LOG =\n      LoggerFactory.getLogger(RouterQuotaUpdateService.class);\n\n  private MountTableStore mountTableStore;\n  private RouterRpcServer rpcServer;\n  /** Router using this Service. */\n  private final Router router;\n  /** Router Quota manager. */\n  private RouterQuotaManager quotaManager;\n\n  public RouterQuotaUpdateService(final Router router) throws IOException {\n    super(RouterQuotaUpdateService.class.getName());\n    this.router = router;\n    this.rpcServer = router.getRpcServer();\n    this.quotaManager = router.getQuotaManager();\n\n    if (this.quotaManager == null) {\n      throw new IOException(\"Router quota manager is not initialized.\");\n    }\n  }\n\n  @Override\n  protected void serviceInit(Configuration conf) throws Exception {\n    this.setIntervalMs(conf.getTimeDuration(\n        RBFConfigKeys.DFS_ROUTER_QUOTA_CACHE_UPDATE_INTERVAL,\n        RBFConfigKeys.DFS_ROUTER_QUOTA_CACHE_UPDATE_INTERVAL_DEFAULT,\n        TimeUnit.MILLISECONDS));\n\n    super.serviceInit(conf);\n  }\n\n  @Override\n  protected void periodicInvoke() {\n    LOG.debug(\"Start to update quota cache.\");\n    try {\n      List<MountTable> mountTables = getQuotaSetMountTables();","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUpdateService.java#L50-L86","documentation":"RouterQuotaUpdateService is the periodic service that keeps the router's in-memory quota cache in sync with the state store. Its constructor fetches router.getQuotaManager() and refuses to start if it is null, because there would be no cache to update. In the standard Router lifecycle the manager is created immediately before this service when dfs.federation.router.quota.enable=true, so seeing this error means that pairing was broken.","triggerScenarios":"The Router constructor takes the quota-enabled branch (dfs.federation.router.quota.enable=true) but router.getQuotaManager() returns null at RouterQuotaUpdateService construction - in practice only reachable via a customized Router/subclass, reflection-driven construction, or a patched router that reorders init; it aborts router startup.","commonSituations":"Custom router deployments or tests constructing RouterQuotaUpdateService directly against a partially initialized Router; forks of Hadoop where quota manager creation was moved or removed but the update service is still added; version skew after applying partial patches.","solutions":["If you run a stock Router, upgrade/patch to a consistent Hadoop build - stock code cannot hit this (manager is created one line earlier in Router.serviceInit)","In custom code, create RouterQuotaManager (set it on the Router) before instantiating RouterQuotaUpdateService, mirroring Router.serviceInit order","If quotas are not needed, set dfs.federation.router.quota.enable=false so neither the manager nor the update service is constructed"],"exampleFix":"// before (custom router code): update service built against uninitialized router\naddService(new RouterQuotaUpdateService(this));  // IOException: Router quota manager is not initialized.\n// after: mirror stock Router.serviceInit\nif (conf.getBoolean(RBFConfigKeys.DFS_ROUTER_QUOTA_ENABLE, RBFConfigKeys.DFS_ROUTER_QUOTA_ENABLED_DEFAULT)) {\n  this.quotaManager = new RouterQuotaManager();\n  addService(new RouterQuotaUpdateService(this));\n}","handlingStrategy":"validation","validationCode":"// Guard service construction order exactly like Router.serviceInit\nif (conf.getBoolean(RBFConfigKeys.DFS_ROUTER_QUOTA_ENABLE, RBFConfigKeys.DFS_ROUTER_QUOTA_ENABLED_DEFAULT)\n    && router.getQuotaManager() != null) {\n  addService(new RouterQuotaUpdateService(router));\n} else {\n  LOG.warn(\"Quota update service skipped: quota disabled or manager missing\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  quotaUpdateService = new RouterQuotaUpdateService(router);\n} catch (IOException e) {\n  if (\"Router quota manager is not initialized.\".equals(e.getMessage())) {\n    // construction-order bug: create RouterQuotaManager on the Router before retrying\n    throw new IllegalStateException(\"Router init order broken: quota manager must precede quota update service\", e);\n  }\n  throw e;\n}","preventionTips":["Never construct RouterQuotaUpdateService standalone; let Router.serviceInit wire it right after RouterQuotaManager","Keep quota enable/disable configured consistently across all routers in the fleet","Run stock Router lifecycle code; forks that reorder init must re-verify this invariant"],"tags":["hdfs","router","federation","quota","initialization","startup","internal-invariant"],"backgroundTag":"service-initialization-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}