← Back to Pull requests

[fix](fe) Return query stats clients to FE pool #70318

Open
unknown opened this pull request with 292 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 06, 2026 03:35 UTC
Author

Background

SHOW QUERY STATS merges local query hit counts with counts from other live Frontends. QueryStatsUtil.getStats() calls each peer through a pooled FE Thrift client.

What problem does this PR solve?

Issue Number: close #70317
Related PR: None
PR Type: Bugfix

Problem Summary: Every remote query stats call borrows a client without returning it, so repeated requests accumulate FE-to-FE connections and can exhaust peer Thrift workers. Return clients after completed RPCs, including skipped responses, and invalidate clients when the RPC fails. Existing query stats results are unchanged.

Details

  • Frequency: Every query stats request that contacts a peer FE.

  • Root cause: QueryStatsUtil.getStats() borrows from ClientPool.frontendPool but has no matching returnObject or invalidateObject call.

  • Why existing tests missed it: Query stats tests did not verify the pooled FE client's lifecycle.

  • Fix: Use a finally block to return a client after a completed RPC or invalidate it after an RPC exception.

  • Other paths and branches: The fix covers all query stats types handled by getStats(), including status checks and empty results. The same leak is present in the 2.1.8 family; a backport may be appropriate.
  • Testing

  • Added FE unit tests for successful response, empty response, non-OK status, RPC failure, and borrow failure. They verify return, invalidation, and the null-client path. The first four tests would fail before the fix.

  • git diff --check passed locally.

  • FE unit tests passed in CI on 09e50c91. The incremental coverage check then reported 7/8 changed lines; abb6dd20 adds the missing borrow-failure case. CI for the new commit is pending. Local FE tests were not run because this sparse checkout lacks the required thirdparty/installed/bin/protoc.
  • Release note

    Repeated SHOW QUERY STATS requests no longer accumulate FE-to-FE Thrift connections.

    Check List (For Author)

  • Behavior changed: Yes (see Details)

  • Does this need documentation: No

  • Pre-submission status: Partially verified: FE unit tests passed on the previous commit; CI for the added coverage case is pending.
  • AI Disclosure

  • Tool: OpenAI Codex (GPT-6).

  • Generated: The fix, FE unit tests, and PR description.

  • Human review: Pending maintainer review.
  • Diff: 292 lines (+219 / -73) across 3 files Reviewer: morrySnow Review duration: 38950m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.40) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 292 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.340
    Real PR Conversation Timeline
    1 comments
    "Review active on #70318"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 39.9% (MEDIUM) · Higher = larger blast radius
    39.9%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 22.8% · Safe to merge
    22.8%
    Repository