Skip to content

NPE in StreamOp.fetchExistingTotalDocs when broker returns exceptions #18490

@Akanksha-kedia

Description

@Akanksha-kedia

Description

StreamOp.fetchExistingTotalDocs in the compatibility verifier crashes with a NullPointerException when the broker response includes exceptions.

Root Cause

The exceptions field in the broker query response is a JSON array (e.g., [{"errorCode": 410, "message": "..."}]), but the code calls exceptions.get("errorCode") as if it were a JSON object. When Jackson's ArrayNode.get(String) is called, it always returns null, causing the subsequent errorCode.asInt() to throw an NPE.

Steps to Reproduce

  1. Run the compatibility verifier while a table's segments are still loading (rolling upgrade scenario)
  2. The broker returns an error response with a non-empty exceptions array
  3. fetchExistingTotalDocs hits the exceptions-handling path and crashes

Expected Behavior

The method should:

  1. Correctly index into the exceptions array (e.g., exceptions.get(0).get("errorCode"))
  2. Handle null defensively
  3. Treat BROKER_SEGMENT_UNAVAILABLE (305) as a transient condition (same as BROKER_INSTANCE_MISSING) and retry

Affected Component

pinot-compatibility-verifier/src/main/java/org/apache/pinot/compat/StreamOp.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions