[GH-ISSUE #4676] [Bug]: Multi-node sync overwrites local client traffic counters when same client email exists on local and node inbounds #3226

Closed
opened 2026-10-31 20:30:56 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Mohamad82Bz on GitHub (May 30, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4676

Describe the bug

When a central panel has a node enabled, and the same client email is attached to both a local inbound and node-backed inbounds, client traffic counters can repeatedly reset to the node's value.

In my case, local Xray traffic accounting was working correctly and x-ui briefly wrote positive up/down values to client_traffics, but less than a second later the node sync overwrote the same client_traffics row back to 0/0.

This happens because client_traffics.email is globally unique, and node sync appears to update traffic by email only, not by the correct inbound/local-vs-node ownership. If the remote node reports 0/0 for the same email, it overwrites the local inbound traffic row.

How to reproduce the problem

  1. Install 3x-ui v3.2.0 on a central panel.
  2. Add a remote node to the central panel.
  3. Create or sync node-backed inbounds.
  4. Attach the same client email to:
    • one local inbound on the central panel
    • one or more node-backed inbounds
  5. Generate traffic through the local central-panel inbound.
  6. Watch the client's traffic in the panel or in SQLite.

Observed pattern:

  • Local Xray stats show nonzero traffic for the client.
  • x-ui writes positive values to client_traffics.
  • Shortly after, node sync overwrites the same row back to 0/0 if the node reports zero traffic for that email.

Expected behavior

Traffic counters from local inbounds and node-backed inbounds should not overwrite each other.

Actual behavior

The same client's traffic counter goes up for a few seconds, then returns to zero or to the node's lower value.

After disabling/removing the node, the local traffic counters stop resetting and increase normally.

Relevant logs

Xray StatsService showed local traffic for the user:

user>>>far-4>>>traffic>>>downlink = 157446889
user>>>far-4>>>traffic>>>uplink   = 138571

But the SQLite row stayed/reset to:

client_traffics.email = far-4
up = 0
down = 0

A temporary SQLite trigger captured this sequence:

local traffic writer:
far-4: 0/0 -> 63/0

node sync shortly after:
far-4: 63/0 -> 0/0

Another example:

local traffic writer:
jafar-conf1: 25933/476652

node sync shortly after:
jafar-conf1: 25933/476652 -> 0/0

The remote node API reported the same clients with `up=0`, `down=0`, while the central/local Xray had nonzero stats.

Screenshots

No response

3x-ui version

3.2.0

Xray-core version

26.5.9

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Statistics / traffic counters, Multi-node (sub-nodes), Backend (API endpoints, login, settings), Database / migrations

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

No — direct access

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 @Mohamad82Bz on GitHub (May 30, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4676 ### Describe the bug When a central panel has a node enabled, and the same client email is attached to both a local inbound and node-backed inbounds, client traffic counters can repeatedly reset to the node's value. In my case, local Xray traffic accounting was working correctly and x-ui briefly wrote positive `up/down` values to `client_traffics`, but less than a second later the node sync overwrote the same `client_traffics` row back to `0/0`. This happens because `client_traffics.email` is globally unique, and node sync appears to update traffic by email only, not by the correct inbound/local-vs-node ownership. If the remote node reports `0/0` for the same email, it overwrites the local inbound traffic row. ### How to reproduce the problem 1. Install 3x-ui v3.2.0 on a central panel. 2. Add a remote node to the central panel. 3. Create or sync node-backed inbounds. 4. Attach the same client email to: - one local inbound on the central panel - one or more node-backed inbounds 5. Generate traffic through the local central-panel inbound. 6. Watch the client's traffic in the panel or in SQLite. Observed pattern: - Local Xray stats show nonzero traffic for the client. - x-ui writes positive values to `client_traffics`. - Shortly after, node sync overwrites the same row back to `0/0` if the node reports zero traffic for that email. ### Expected behavior Traffic counters from local inbounds and node-backed inbounds should not overwrite each other. ### Actual behavior The same client's traffic counter goes up for a few seconds, then returns to zero or to the node's lower value. After disabling/removing the node, the local traffic counters stop resetting and increase normally. ### Relevant logs ```shell Xray StatsService showed local traffic for the user: user>>>far-4>>>traffic>>>downlink = 157446889 user>>>far-4>>>traffic>>>uplink = 138571 But the SQLite row stayed/reset to: client_traffics.email = far-4 up = 0 down = 0 A temporary SQLite trigger captured this sequence: local traffic writer: far-4: 0/0 -> 63/0 node sync shortly after: far-4: 63/0 -> 0/0 Another example: local traffic writer: jafar-conf1: 25933/476652 node sync shortly after: jafar-conf1: 25933/476652 -> 0/0 The remote node API reported the same clients with `up=0`, `down=0`, while the central/local Xray had nonzero stats. ``` ### Screenshots _No response_ ### 3x-ui version 3.2.0 ### Xray-core version 26.5.9 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Statistics / traffic counters, Multi-node (sub-nodes), Backend (API endpoints, login, settings), Database / migrations ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? No — direct access ### 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:30:56 +07:00
  • closed this issue
  • added the
    bug
    label
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#3226
No description provided.