- [Account Pool Scheduling Total Order Hardening & Panic Root-Cause Fix] Fix Rust Slice Sort Panic and Empty Reply Caused by Non-Transitive Reset Time Comparison (Fixes #3570, Thanks to @Xyloz3n):
- Strict Total Order Construction & Elimination of Flawed Threshold: Removed the non-transitive 600-second threshold in
tokens_snapshot.sort_by. When accounts had reset times straddling the 600s boundary, the comparator produced non-transitive equivalence cycles (A == B, B == C, but A < C), triggering internal Rust stdsmallsort / driftsortpanics (user-provided comparison function does not correctly implement a total order) and sudden client disconnects (Empty reply from server). Refactored to direct scalar comparisonreset_a.cmp(&reset_b), mathematically guaranteeing total order under all account distributions. - Deterministic Account ID Tie-Breaker: Added
a.account_id.cmp(&b.account_id)as a final tie-breaker when tier, quota, health score, and reset time are identical (e.g. during warmup clustering), ensuring stable, reproducible ordering even in highly homogeneous account pools. - Unit Tests & Dense Account Pool Mock Regression: Updated
compare_tokenstest harness; addedtest_sorting_transitivity_no_panic_issue_3570testing mathematical transitivity andtest_sorting_large_account_pool_dense_reset_times_issue_3570stress-testing 200+ accounts with dense reset times without panic.
- Strict Total Order Construction & Elimination of Flawed Threshold: Removed the non-transitive 600-second threshold in
- [账号池调度算法严格全序治理与 Panic 根治] 修复重置时间比较函数破坏全序传递性导致的 Rust sort panic 与请求空回复 (Fixes #3570, Thanks to @Xyloz3n):
- 严格全序关系构建与容差带彻底废除: 彻底移除
tokens_snapshot.sort_by中将相差小于 10 分钟(600 秒)视为等价的非传递性模糊容差逻辑。该逻辑在多账号候选池且reset_time分散跨越 600 秒边界时,必然构成 A == B, B == C 但 A < C 的非传递三元环,触发 Rust 1.81+ 标准库smallsort / driftsort内部断言 panic 并导致 HTTP 连接异常断开(Empty reply from server)。重构为严格的标量时间比较reset_a.cmp(&reset_b),从数学原理上彻底根除崩溃隐患。 - 确定性 Tie-breaker 保底决胜机制: 在订阅等级、目标模型配额、健康度以及重置时间均相同(如批量账号 warmup 对齐到同一秒)的极端同质化池场景下,引入
a.account_id.cmp(&b.account_id)作为终极保底决胜条件,确保排序结果具备严格自反性、反对称性与传递性,排序结果稳定可预期。 - 单元测试与高密度账号池 Mock 回归覆盖: 同步重构
compare_tokens测试比较函数;新增test_sorting_transitivity_no_panic_issue_3570验证三元反例传递性,以及test_sorting_large_account_pool_dense_reset_times_issue_3570针对 200+ 高密度账号池的真实场景无 panic 压力回归测试。
- 严格全序关系构建与容差带彻底废除: 彻底移除
Full Changelog: v4.8.7...v4.8.8