3x-ui/internal/database
MHSanaei 837cf5f24e fix(db): clamp traffic counters below int64 max and repair overflowed rows
A counter pushed past int64 (multi-node setups hit this via historic
delta-compounding bugs) makes SQLite silently promote the INTEGER cell
to REAL. From then on the column no longer scans into the Go int64
field and every reader of client_traffics fails at once: the inbounds
page, xray restarts, and node traffic sync all return "converting
driver.Value type float64 to int64".

Two-part fix: every unbounded "up = up + ?" add (local traffic, node
delta merge, inbound counters, plus the Go-side outbound accumulation)
now saturates at TrafficMax, a cap safely below math.MaxInt64 so one
more delta cannot overflow; and a startup repair casts REAL-promoted
cells back to INTEGER and clamps all traffic counters into
[0, TrafficMax] across client_traffics, inbounds, outbound_traffics
and node_client_traffics, restoring access to already-corrupted panels
without manual sqlite surgery.

Closes #5762
2026-07-05 20:33:09 +02:00
..
model fix(sub): bake Host VLESS Route into subscription UUIDs 2026-06-29 14:32:23 +02:00
api_token_timestamp_test.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
db.go fix(db): clamp traffic counters below int64 max and repair overflowed rows 2026-07-05 20:33:09 +02:00
db_seed_test.go fix(settings): repair legacy path settings that block every settings save 2026-07-02 13:42:03 +02:00
db_settled_test.go fix(database): stop noisy per-startup errors in the Postgres server log 2026-07-01 23:07:05 +02:00
dialect.go fix(db): clamp traffic counters below int64 max and repair overflowed rows 2026-07-05 20:33:09 +02:00
dump_sqlite.go style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
dump_sqlite_test.go
host_migration_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
host_test.go feat(hosts): managed Hosts for per-host subscription link overrides (#5409) 2026-06-17 12:06:55 +02:00
index_tags_test.go fix: resolve a batch of open bug-tagged issues (traffic accounting, share strategy, sub address, CPU) (#5477) 2026-06-22 00:22:28 +02:00
migrate_data.go fix(database): stop noisy per-startup errors in the Postgres server log 2026-07-01 23:07:05 +02:00
migrate_data_test.go
settings_index_test.go perf(db): add an index on settings.key (#5359) 2026-06-20 15:08:54 +03:30
traffic_overflow_repair_test.go fix(db): clamp traffic counters below int64 max and repair overflowed rows 2026-07-05 20:33:09 +02:00
wireguard_migration_test.go feat(wireguard): multi-client support 2026-06-28 00:44:38 +02:00