mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5028] [Bug]: Per-client traffic usage stuck at 0 on subscription page after upgrading to v3.2.8 (multi-node, worked in v3.2.7) #3542
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#3542
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 @Namso9 on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5028
Describe the bug
Describe the bug
After upgrading from v3.2.7 to v3.2.8, per-client traffic usage no longer appears. On the subscription info page, Downloaded, Uploaded and Usage all stay at 0.00B, and “Last Online” shows -, even though clients are connected and actively using the connection. The total quota and remaining quota display correctly (e.g. 200.00GB), but consumed traffic is never recorded.
This worked correctly in v3.2.7 — per-client used data was displayed properly. The problem started only after upgrading to v3.2.8.
• This is a multi-node deployment managed from a master panel (nodes across several regions).
• Clients are shared across inbounds/nodes.
• Subscription service is enabled and serving config to clients normally (connectivity works fine — only the traffic accounting is broken).
How to reproduce the problem
Expected behavior
Per-client used traffic should increment and be reflected on the subscription page and in the client traffic stats, as it did in v3.2.7.
Actual behavior
v3.2.8 includes the commit fix(traffic): count local traffic for clients whose shared row is node-owned (#4921). Since the affected clients are node-owned shared rows in a multi-node setup, this change may be related to the regression.
Relevant logs
Screenshots
3x-ui version
3.2.8
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Subscription (share links / Clash / JSON)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 6, 2026):
Thanks for the thorough write-up and for pointing at the relevant commit.
What the code actually does
Per-client traffic on the master in a multi-node setup flows exclusively through
web/job/node_traffic_sync_job.go→web/service/inbound.go:setRemoteTrafficLocked. The mechanism is delta-based using thenode_client_trafficstable (one baseline row per(node_id, email)):/panel/api/inbounds/list).deltaUp = cs.Up − baseline.Up(clamped to 0 if the counter reset), then runs:The
fix(traffic): count local traffic for clients whose shared row is node-owned (#4921)change you identified only affectsaddClientTraffic, which is the local-xray poll path (called byXrayTrafficJob, not by the node-sync job). For a master panel whose clients connect exclusively through remote nodes (not a local Xray instance on the master), that change is a no-op for your setup.The change that does touch the node-sync UPDATE is #4917 (
fix(node-traffic): prevent stale node snapshot from re-enabling disabled client), which replacedenable = ?withenable = enable AND ?. This is harmless for enabled clients (1 AND 1 = 1), but there is a plausible scenario where it interacts with a stale first-sync:What to check
1. Are nodes actually online and syncing?
On the master server:
Look for
node traffic sync: fetch from <NodeName> failed— any error here means no traffic is merged for that node that tick.2. Does the master's DB show any traffic at all?
If
up,down, andlast_onlineare all 0, the UPDATE is either not running or always applyingdelta = 0.3. Does the baseline table have rows?
If this is empty, the first sync never ran (node offline, auth failure, tag mismatch). If it has rows, compare the stored
up/downto what the node's own DB shows — they should be close or equal when traffic is active.4. Does the node itself show the traffic?
Log in to one of the node panels and check the client's stats there. If the node panel shows
up + down > 0but the master shows 0, the sync is running but failing to merge — likely a tag-lookup miss insetRemoteTrafficLocked(tagToCentrallookup atinbound.go:~1750).5. Do all nodes show as "online" on the master Nodes page? If any show as offline or with a warning badge, those nodes' traffic is never fetched.
Suspected root cause
Given that this regressed specifically in v3.2.8, the most likely culprits (beyond connectivity) are:
enable AND ?interaction: if any client was left inenable = falseon the master (e.g. a previous depletion event) and the node now sendscs.Enable = true, the master keepsenable = false. This only affects the enable column, not up/down, so it is not directly the cause of "stuck at 0."tagToCentralto not find the node's inbound (ok = false→ entire inbound's clients skipped). Check whether node inbound tags in the panel exactly match what the node reports.node_client_trafficsquery above, that would narrow it down significantly.Please also confirm: does the master panel run its own local Xray (i.e. do any clients connect directly to the master, not through a node)? That determines whether #4921 could be in the path at all.
@Namso9 commented on GitHub (Jun 6, 2026):
Follow-up: confirmed — this is a Postgres-only regression in the node-traffic sync CASE expression
Thanks for the detailed breakdown. The logs point to a clear root cause, and it's not connectivity or a tag mismatch — it's a SQL type error in the merge query that only happens on PostgreSQL.
Logs (master, v3.2.8, all nodes failing identically):
Jun 07 03:07:29 ubuntu x-ui[2085]: WARNING - node traffic sync: merge for THAI 2 failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
Jun 07 03:07:29 ubuntu x-ui[2085]: WARNING - node traffic sync: merge for SINGAPORE failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
Jun 07 03:07:29 ubuntu x-ui[2085]: WARNING - node traffic sync: merge for THAILAND failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
Jun 07 03:07:29 ubuntu x-ui[2085]: WARNING - node traffic sync: merge for JAPAN failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
Jun 07 03:07:29 ubuntu x-ui[2085]: WARNING - node traffic sync: merge for MALAYSIA failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
This repeats every ~5 seconds for all 5 nodes. Every node's setRemoteTrafficLocked merge fails, so the UPDATE client_traffics ... never runs — which is exactly why per-client up/down/last_online stay at 0 and the subscription page shows 0.00B despite active traffic.
Root cause:
SQLSTATE 42804 is a PostgreSQL error. The #4917 change (fix(node-traffic): prevent stale node snapshot from re-enabling disabled client) replaced enable = ? with an enable = enable AND ? style expression in the node-sync merge. On PostgreSQL, the CASE (or AND) construct requires all branches to resolve to a single compatible type, and here a boolean column (enable) is being combined with an integer value, so Postgres rejects the whole statement. On SQLite this is silently fine because boolean and integer are interchangeable, so the bug is invisible on the default backend.
Decisive evidence — it only breaks on Postgres:
On v3.2.7 with the SQLite backend, per-client traffic accounting worked correctly.
The traffic-stuck-at-0 problem started only after migrating the master DB to PostgreSQL (still seeing it on v3.2.8).
Same topology, same nodes, same clients — the only variable that changed is the storage backend. That isolates the failure to a Postgres type-compatibility issue in the node-sync enable expression, not to connectivity, tags, or #4921.
Environment:
3x-ui: v3.2.8 (master + 5 remote nodes)
Master DB backend: PostgreSQL (was SQLite on v3.2.7, where it worked)
OS: Ubuntu
Suggested fix: cast the boolean to integer (or the integer to boolean) consistently inside the enable branch of the node-sync merge so the expression is type-uniform on Postgres — e.g. compare/assign enable against a boolean-typed parameter rather than an integer, or wrap with an explicit CAST. Happy to test a patch against this multi-node Postgres setup.
@ahmetakdag101 commented on GitHub (Jun 7, 2026):
I had the same issue on a multi-node setup.
In my case:
Main panel was running 3x-ui v3.2.8
Remote nodes were also visible and online
Clients could connect to the nodes successfully
Traffic and online status were visible on the node panels
But the main/accounting panel did not show the user as online and did not update the traffic usage
The main panel logs showed errors like:
WARNING - node traffic sync: merge for s521-node-01 failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
WARNING - node traffic sync: merge for s521-node-02 failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
WARNING - node traffic sync: merge for s521-node-03 failed: ERROR: CASE types boolean and integer cannot be matched (SQLSTATE 42804)
Temporary workaround:
I downgraded only the main/accounting panel from v3.2.8 to v3.2.7.
I did not downgrade the remote nodes. The nodes stayed on v3.2.8.
After downgrading the main panel to v3.2.7, the node traffic sync error disappeared and the main panel started receiving traffic/online status correctly again.
So for now, as a temporary workaround, downgrading only the main panel to v3.2.7 may be enough until this is fixed in a future release.
@rqzbeh commented on GitHub (Jun 7, 2026):
I've attached this commit, hope this would fix the problem:
https://github.com/MHSanaei/3x-ui/pull/5038
@claude @MHSanaei
@MHSanaei commented on GitHub (Jun 11, 2026):
Fixed in
21e01cc1(shipped in v3.3.0). The node traffic sync merge used a SQL CASE expression that PostgreSQL rejected with a boolean/integer type error, so per-client counters were never updated after the v3.2.8 upgrade and the subscription page showed 0. The merge expression is now dialect-aware. Additionally,58905d81makes the master push aggregated global usage to nodes for display. Please upgrade to v3.3.0 or later and reopen if usage is still stuck at 0.