{"record":{"id":"07dd6a960802c641","repo":"apache/hadoop","slug":"caching-path-path-of-size-stats-getbytesneeded","errorCode":null,"errorMessage":"Caching path path of size stats.getBytesNeeded() / replication bytes at replication replication would exceed pool pool.getPoolName()'s remaining capacity of (pool.getLimit() - pool.getBytesNeeded()) bytes.","messagePattern":"Caching path path of size stats\\.getBytesNeeded\\(\\) / replication bytes at replication replication would exceed pool pool\\.getPoolName\\(\\)'s remaining capacity of \\(pool\\.getLimit\\(\\) - pool\\.getBytesNeeded\\(\\)\\) bytes\\.","errorType":"exception","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java","lineNumber":464,"sourceCode":"  }\n\n  /**\n   * Throws an exception if the CachePool does not have enough capacity to\n   * cache the given path at the replication factor.\n   *\n   * @param pool CachePool where the path is being cached\n   * @param path Path that is being cached\n   * @param replication Replication factor of the path\n   * @throws InvalidRequestException if the pool does not have enough capacity\n   */\n  private void checkLimit(CachePool pool, String path,\n      short replication) throws InvalidRequestException {\n    CacheDirectiveStats stats = computeNeeded(path, replication);\n    if (pool.getLimit() == CachePoolInfo.LIMIT_UNLIMITED) {\n      return;\n    }\n    if (pool.getBytesNeeded() + stats.getBytesNeeded() > pool.getLimit()) {\n      throw new InvalidRequestException(\"Caching path \" + path + \" of size \"\n          + stats.getBytesNeeded() / replication + \" bytes at replication \"\n          + replication + \" would exceed pool \" + pool.getPoolName()\n          + \"'s remaining capacity of \"\n          + (pool.getLimit() - pool.getBytesNeeded()) + \" bytes.\");\n    }\n  }\n\n  /**\n   * Computes the needed number of bytes and files for a path.\n   * @return CacheDirectiveStats describing the needed stats for this path\n   */\n  private CacheDirectiveStats computeNeeded(String path, short replication) {\n    FSDirectory fsDir = namesystem.getFSDirectory();\n    INode node;\n    long requestedBytes = 0;\n    long requestedFiles = 0;\n    CacheDirectiveStats.Builder builder = new CacheDirectiveStats.Builder();\n    try {","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/CacheManager.java#L446-L482","documentation":"Error \"Caching path path of size stats.getBytesNeeded() / replication bytes at replication replication would exceed pool pool.getPoolName()'s remaining capacity of (pool.getLimit() - pool.getBytesNeeded()) bytes.\" thrown in apache/hadoop.","triggerScenarios":"addCacheDirective when caching the path at the given replication would exceed the cache pool's remaining byte limit.","commonSituations":"See trigger scenarios.","solutions":["Increase the cache pool's limit with hdfs cacheadmin -modifyPool -limit, or reduce the path's size/replication so it fits in remaining capacity.","Remove other directives from the pool to free capacity."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}