mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4286] [3.0.1] addClientTraffic fails with "too many SQL variables" for >2978 clients #2924
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#2924
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jakobmelti on GitHub (May 12, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4286
Describe the bug
Bug
At web/service/inbound.go:1921,
tx.Save(dbClientTraffics)attempts to saveall client traffic records in a single SQL statement. With >2978 clients
(32766 SQLite max variables / 11 fields), SQLite rejects the batch and
NO traffic is recorded for ANY client.
Reproduce
Impact
All deployments with >2978 clients have completely broken traffic accounting.
Fix
Use CreateInBatches or chunk the save loop:
How to repeat the problem?
journalctl -u x-ui -f)"WARNING - X-UI: AddClientTraffic update data too many SQL variables"
The bug triggers because web/service/inbound.go:1921 calls tx.Save(dbClientTraffics)
with ALL clients in a single SQL statement. With 11 DB-persisted fields per
ClientTraffic struct (id, inbound_id, enable, email, up, down, all_time,
expiry_time, total, reset, last_online), the placeholder count is:
client_count × 11 = total SQL placeholders
SQLite's SQLITE_MAX_VARIABLE_NUMBER default is 32766 (since SQLite 3.32, May 2020).
Maximum safe client count: 32766 ÷ 11 = 2978 clients
Beyond 2978 clients, EVERY traffic update fails with "too many SQL variables"
and traffic accounting is COMPLETELY broken for the entire deployment.
In my deployment (7399 clients), the failure rate is 100% — no traffic is
ever recorded. All counters in the panel show 0 or stale values.
Expected action
No response
Received action
No response
3x-ui Version
3.0.1
Xray-core Version
No response
Checklist