apache/hadoop · error · IllegalStateException

ReadBuffer refCount cannot be negative

Error message

ReadBuffer refCount cannot be negative

What it means

Error "ReadBuffer refCount cannot be negative" thrown in apache/hadoop.

Source

Thrown at hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/services/ReadBuffer.java:165

  public ReadBufferStatus getStatus() {
    return status;
  }

  public void setStatus(ReadBufferStatus status) {
    this.status = status;
    if (status == READ_FAILED) {
      bufferindex = -1;
    }
  }

  public void startReading() {
    refCount.getAndIncrement();
  }

  public void endReading() {
    if (refCount.decrementAndGet() < 0) {
      throw new IllegalStateException("ReadBuffer refCount cannot be negative");
    }
  }

  public int getRefCount() {
    return refCount.get();
  }

  public CountDownLatch getLatch() {
    return latch;
  }

  public void setLatch(CountDownLatch latch) {
    this.latch = latch;
  }

  public long getTimeStamp() {
    return timeStamp;
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. This indicates a buffer lifecycle bug; avoid double-release of read buffers in custom code.
  2. Upgrade hadoop-azure and report with logs if observed in stock usage.

When it happens

Trigger: A ReadBuffer's reference count goes negative, i.e. released more times than acquired.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/d33b4ea47c974f19. Report an issue: GitHub.