← Back to Pull requests

fix(test): retry Kafka partition readiness #19948

Closed
unknown closed this pull request without merging on Aug 11, 2026 05:18 UTC
View on GitHub
unknown unknown commented on Aug 10, 2026 03:49 UTC
Author

Description

This is a follow-up to #19922 that hardens the embedded Kafka test resource against the topic metadata propagation race observed during that PR's CI run.

KafkaResource.createTopicWithPartitions() waits for the topic-creation future, but Kafka can acknowledge creation before the topic metadata and partition leaders are ready for a subsequent listOffsets request. The existing waitForPartitionsToBeReady() performed that request only once, so the test setup could fail with UnknownTopicOrPartitionException during the propagation window.

This PR:

  • retries the partition latest-offset readiness probe up to five times with Druid's retry backoff;

  • retries only Kafka RetriableException instances, including exceptions nested in ExecutionException;

  • keeps the readiness check shared by both topic creation and partition expansion.
  • There is no end-user behavior change; this only stabilizes embedded test setup.

    Evidence

  • PR #19922 run 31319365598, failed job 93259746963, reported one error in KafkaIndexFaultToleranceTest.

  • The stack trace was KafkaFutureImpl.get -> KafkaResource.waitForPartitionsToBeReady -> KafkaResource.createTopicWithPartitions, with UnknownTopicOrPartitionException as the cause.

  • The same topic-readiness error occurred in an unrelated historical job (job 93262496826), while nearby runs passed, confirming a timing-dependent failure.

  • Before this change, the focused fault-tolerance test passed locally twice but did not eliminate the one-shot readiness race. After this change, KafkaResourceTest passed (1 test), and the focused fault-tolerance test passed twice, including both parameterizations: 9 tests, 0 failures, 0 errors on each run.
  • Validation

    mvn -B -ntp -Pskip-static-checks -pl extensions-core/kafka-indexing-service -am test \
      -Dtest=org.apache.druid.indexing.kafka.simulate.KafkaResourceTest \
      -Dsurefire.failIfNoSpecifiedTests=false -Dweb.console.skip=true -T1C
    
    mvn -B -ntp -Pskip-static-checks -pl embedded-tests -am test \
      -Dtest=org.apache.druid.testing.embedded.indexing.KafkaIndexFaultToleranceTest \
      -Dsurefire.failIfNoSpecifiedTests=false -Dweb.console.skip=true -T1C
    
    mvn -B -ntp -pl extensions-core/kafka-indexing-service -am -DskipTests \
      -Dweb.console.skip=true checkstyle:check pmd:check forbiddenapis:check forbiddenapis:testCheck
    

    All commands passed locally.

    Diff: 323 lines (+242 / -81) across 4 files Reviewer: abhishekrb19 Review duration: 1528m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 323 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #19948"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.0% (MEDIUM) · Higher = larger blast radius
    42.0%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.1% · Safe to merge
    18.1%
    Repository