fix(loadbalancer): avoid int overflow of uptime in warmup weight calculation #8005
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.35 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Approved
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.
Aias00
Duansg
What
AbstractLoadBalancer#getWeightcomputedint uptime = (int) (now - timestamp). The timestamp comes from the upstream'sdateCreatedor registration time, so for long-running upstreams the cast overflows:uptime > 0check fails, so full weight is returned and there is no visible impact.(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
uptimeaslongfor the comparison, and cast tointonly inside the warmup window.Tests
Added
AbstractLoadBalancerTestcovering: 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:
./mvnw clean install -Dmaven.javadoc.skip=true.