[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

Closed
opened 2026-10-31 20:33:11 +07:00 by bsakaguchi · 5 comments
Owner

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

1.	Upgrade an existing multi-node setup from v3.2.7 to v3.2.8.
2.	Connect a client and generate traffic (download/stream).
3.	Open the client’s subscription page.
4.	Observe: Downloaded / Uploaded / Usage remain at 0.00B, Last Online stays .

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

Image

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

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
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 1. Upgrade an existing multi-node setup from v3.2.7 to v3.2.8. 2. Connect a client and generate traffic (download/stream). 3. Open the client’s subscription page. 4. Observe: Downloaded / Uploaded / Usage remain at 0.00B, Last Online stays . ### 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 ```shell ``` ### Screenshots <img width="1290" height="1820" alt="Image" src="https://github.com/user-attachments/assets/c5b304f4-7696-402b-a39e-6e987058e407" /> ### 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 - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:33:11 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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 the node_client_traffics table (one baseline row per (node_id, email)):

  1. The sync job fetches each online node's inbound list (/panel/api/inbounds/list).
  2. For every client in the snapshot, it computes deltaUp = cs.Up − baseline.Up (clamped to 0 if the counter reset), then runs:
    UPDATE client_traffics
    SET up = up + ?, down = down + ?, ..., last_online = MAX(last_online, ?)
    WHERE email = ?
    
  3. After the update it upserts the baseline to the current absolute counter so the next tick only adds the new increment.

The fix(traffic): count local traffic for clients whose shared row is node-owned (#4921) change you identified only affects addClientTraffic, which is the local-xray poll path (called by XrayTrafficJob, 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 replaced enable = ? with enable = 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:

On the very first sync after the upgrade, if the baseline row is missing, deltaUp = 0 is added and the baseline is seeded. That tick correctly writes zero. Every subsequent tick should accumulate the new delta. If up and down are permanently stuck at zero even after minutes of traffic, it usually means the UPDATE is either never reaching the delta step or the node counter (cs.Up) is itself always 0.

What to check

1. Are nodes actually online and syncing?

On the master server:

journalctl -u x-ui -f | grep -E "node traffic sync|node heartbeat|fetch from"

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?

sqlite3 /etc/x-ui/x-ui.db \
  "SELECT email, up, down, last_online FROM client_traffics WHERE email IN ('<one of your client emails>') LIMIT 5;"

If up, down, and last_online are all 0, the UPDATE is either not running or always applying delta = 0.

3. Does the baseline table have rows?

sqlite3 /etc/x-ui/x-ui.db "SELECT * FROM node_client_traffics LIMIT 10;"

If this is empty, the first sync never ran (node offline, auth failure, tag mismatch). If it has rows, compare the stored up/down to 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 > 0 but the master shows 0, the sync is running but failing to merge — likely a tag-lookup miss in setRemoteTrafficLocked (tagToCentral lookup at inbound.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:

  • The enable AND ? interaction: if any client was left in enable = false on the master (e.g. a previous depletion event) and the node now sends cs.Enable = true, the master keeps enable = false. This only affects the enable column, not up/down, so it is not directly the cause of "stuck at 0."
  • A tag-prefix mismatch causing tagToCentral to 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.
  • An unrelated regression only visible in your specific topology. If you can share the output of the log command and the node_client_traffics query 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.

<!-- gh-comment-id:4640281462 --> @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 the `node_client_traffics` table (one baseline row per `(node_id, email)`): 1. The sync job fetches each online node's inbound list (`/panel/api/inbounds/list`). 2. For every client in the snapshot, it computes `deltaUp = cs.Up − baseline.Up` (clamped to 0 if the counter reset), then runs: ```sql UPDATE client_traffics SET up = up + ?, down = down + ?, ..., last_online = MAX(last_online, ?) WHERE email = ? ``` 3. After the update it upserts the baseline to the current absolute counter so the next tick only adds the new increment. The `fix(traffic): count local traffic for clients whose shared row is node-owned (#4921)` change you identified only affects `addClientTraffic`, which is the **local-xray** poll path (called by `XrayTrafficJob`, 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 replaced `enable = ?` with `enable = 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: > On the very first sync after the upgrade, if the baseline row is missing, `deltaUp = 0` is added and the baseline is seeded. **That tick correctly writes zero.** Every subsequent tick should accumulate the new delta. If `up` and `down` are permanently stuck at zero even after minutes of traffic, it usually means the UPDATE is either never reaching the delta step or the node counter (`cs.Up`) is itself always 0. ## What to check **1. Are nodes actually online and syncing?** On the master server: ```bash journalctl -u x-ui -f | grep -E "node traffic sync|node heartbeat|fetch from" ``` 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?** ```bash sqlite3 /etc/x-ui/x-ui.db \ "SELECT email, up, down, last_online FROM client_traffics WHERE email IN ('<one of your client emails>') LIMIT 5;" ``` If `up`, `down`, and `last_online` are all 0, the UPDATE is either not running or always applying `delta = 0`. **3. Does the baseline table have rows?** ```bash sqlite3 /etc/x-ui/x-ui.db "SELECT * FROM node_client_traffics LIMIT 10;" ``` If this is empty, the first sync never ran (node offline, auth failure, tag mismatch). If it has rows, compare the stored `up`/`down` to 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 > 0` but the master shows 0, the sync is running but failing to merge — likely a tag-lookup miss in `setRemoteTrafficLocked` (`tagToCentral` lookup at `inbound.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: - **The `enable AND ?` interaction**: if any client was left in `enable = false` on the master (e.g. a previous depletion event) and the node now sends `cs.Enable = true`, the master keeps `enable = false`. This only affects the enable column, not up/down, so it is not directly the cause of "stuck at 0." - **A tag-prefix mismatch** causing `tagToCentral` to 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. - **An unrelated regression** only visible in your specific topology. If you can share the output of the log command and the `node_client_traffics` query 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.
Author
Owner

@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.

<!-- gh-comment-id:4640314828 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:4641261471 --> @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.
Author
Owner

@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

<!-- gh-comment-id:4641486441 --> @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
Author
Owner

@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, 58905d81 makes 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.

<!-- gh-comment-id:4685768465 --> @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, 58905d81 makes 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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3542
No description provided.