{"record":{"id":"e96373944c044857","repo":"apache/hadoop","slug":"wait-failed-for-acquire-d","errorCode":null,"errorMessage":"Wait failed for acquire(%d)","messagePattern":"Wait failed for acquire\\((.+?)\\)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/prefetch/BufferPool.java","lineNumber":148,"sourceCode":"\n    do {\n      if (retryer.updateStatus()) {\n        if (LOG.isDebugEnabled()) {\n          LOG.debug(\"waiting to acquire block: {}\", blockNumber);\n          LOG.debug(\"state = {}\", this);\n        }\n        releaseReadyBlock(blockNumber);\n      }\n      data = tryAcquire(blockNumber);\n    }\n    while ((data == null) && retryer.continueRetry());\n\n    if (data != null) {\n      return data;\n    } else {\n      String message =\n          String.format(\"Wait failed for acquire(%d)\", blockNumber);\n      throw new IllegalStateException(message);\n    }\n  }\n\n  /**\n   * Acquires a buffer if one is immediately available. Otherwise returns null.\n   * @param blockNumber the id of the block to try acquire.\n   * @return the acquired block's {@code BufferData} or null.\n   */\n  public synchronized BufferData tryAcquire(int blockNumber) {\n    return acquireHelper(blockNumber, false);\n  }\n\n  private synchronized BufferData acquireHelper(int blockNumber,\n      boolean canBlock) {\n    checkNotNegative(blockNumber, \"blockNumber\");\n\n    releaseDoneBlocks();\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/prefetch/BufferPool.java#L130-L166","documentation":"BufferPool.acquire(blockNumber) loops (tryAcquire plus waiting on ready blocks under a bounded Retryer) until it holds that block's BufferData. If the retry budget is exhausted while the block is still owned elsewhere or never becomes available, it throws IllegalStateException(\"Wait failed for acquire(N)\") — the pool was never able to hand the block over.","triggerScenarios":"More concurrent readers than pool buffers, each pinning blocks without releasing; a leaked BufferData (missing release() on a failure path) starving later acquires; waiter signalling that never fires so every retry attempt finds the block unavailable.","commonSituations":"High reader concurrency on prefetching input streams; exceptions between acquire and release skipping cleanup; pool sized far below the working set of in-flight blocks (configuration too small).","solutions":["Guarantee release(): wrap every acquire/use region in try/finally calling data.release()","Lower reader concurrency or raise the buffer pool size so demand stays under capacity","Instrument acquire/release pairs and log outstanding block ownership when exhaustion repeats","Check for hold-and-wait deadlock (thread holding one block while acquiring another); order acquisitions or use tryAcquire with a fallback"],"exampleFix":"// before\nBufferData data = bufferPool.acquire(blockNumber);\nuse(data);              // if this throws, the block leaks -> later IllegalStateException\n\n// after\nBufferData data = bufferPool.acquire(blockNumber);\ntry {\n  use(data);\n} finally {\n  data.release();       // block returns to the pool on every path\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch IllegalStateException(\"Wait failed for acquire\") at the read boundary; treat it as pool exhaustion — release any blocks the caller holds, reduce concurrency, and retry once with fewer readers rather than looping on the same path.","preventionTips":["Always release BufferData in a finally block right after use","Size the buffer pool above peak concurrent readers","Avoid hold-and-wait: acquire blocks in a fixed order or use tryAcquire","Log acquire/release balance when exhaustion first appears to catch leaks early"],"tags":["hadoop","prefetch","buffer-pool","concurrency","resource-leak"],"backgroundTag":"pool-exhaustion","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}