← Back to Pull requests

fix(loadbalancer): avoid int overflow of uptime in warmup weight calculation #8005

Merged
Duansg merged 2 files (87 lines) on Oct 24, 2026 03:27 UTC
View on GitHub
Duansg Duansg commented on Oct 23, 2026 02:51 UTC
Author

What

AbstractLoadBalancer#getWeight computed int uptime = (int) (now - timestamp). The timestamp comes from the upstream's dateCreated or registration time, so for long-running upstreams the cast overflows:

  • After ~24.8 days, uptime becomes negative. The uptime > 0 check fails, so full weight is returned and there is no visible impact.

  • After ~49.7 days (2^32 ms), the low 32 bits fall into (0, warmup) again. The upstream's weight drops to near 1 and ramps back up over the default 10-minute warmup. This repeats every 49.7 days.
  • How

    Keep uptime as long for the comparison, and cast to int only inside the warmup window.

    Tests

    Added AbstractLoadBalancerTest covering: within warmup, after warmup, uptime > Integer.MAX_VALUE, and uptime = 2^32 ms + 5 min. Without the fix, the last case fails (expected: <100> but was: <50>).

    Make sure that:

  • You have read the contribution guidelines.

  • You submit test cases (unit or integration tests) that back your changes.

  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.
  • Diff: 87 lines (+85 / -2) across 2 files Reviewer: Aias00 Review duration: 1476m
    All Vouch review confidence checks passed
    Residual risk 0.11 = Change Risk (0.31) × (1 − Review Confidence (0.64)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.31 · 87 lines diff across 2 files
    0.31
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.35 · 1 substantive comment(s)
    0.35
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    63%
    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.268
    Real PR Conversation Timeline
    2 items
    Aias00 Aias00 approved these changes on Oct 23, 2026 06:13 UTC
    Approved Reviewer

    LGTM. The overflow was real: (int) (System.currentTimeMillis() - timestamp) truncates the low 32 bits, so an upstream older than ~24.8 days could land back inside the warmup window and get a reduced weight. Widening uptime to long and only narrowing inside the uptime < warmup branch is safe because warmup is an int.

    The regression tests are well chosen, especially fullWeightWhenUptimeLowBitsFallInWarmupTest, which pins the exact truncation case.

    Reviewers
    Assignees
    Duansg Duansg
    Labels
    risk: low confidence: 63.7% 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: 31.2% (LOW) · Higher = larger blast radius
    31.2%
    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: 63.7% · Lower = rushed or shallow review
    63.7%
    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: 11.3% · Safe to merge
    11.3%
    Repository