mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5411] [Bug]: Client traffic reset on local panel does not persist and restores previous usage #3784
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#3784
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 @Arlo0321 on GitHub (Jun 17, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5411
Describe the bug
When resetting traffic for an individual client from the Clients page, the traffic counter is cleared at first, but the reset does not persist. After some time or after reloading the page, the client's previous traffic usage is displayed again.
This issue occurs on a standalone/local 3x-ui panel. No master panel, remote node, or slave synchronization is involved.
How to reproduce the problem
Install and start 3x-ui.
Create a local inbound.
Add one or more clients.
Allow a client to generate traffic.
Open the Clients page.
Click Reset Traffic for a specific client.
Confirm that the traffic value becomes zero.
Refresh the page or wait for some time.
Observe that the previous traffic value reappears.
Expected behavior
Traffic usage for the selected client should remain at 0 after clicking Reset Traffic.
The reset operation should affect only the chosen client and should not impact other clients or inbounds.
Actual behavior
The traffic counter is cleared only temporarily. After a refresh or after some time passes, the old traffic statistics are restored.
Relevant logs
Screenshots
3x-ui version
3.3.1
Xray-core version
26.6.1
How did you install 3x-ui?
install.sh script
Operating system
Debian 13
Which parts of the panel are affected?
No response
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 17, 2026):
This is a duplicate of #5390, which was filed by the same author and describes the identical issue. Further discussion and any fix should happen in #5390.
For context on what the code does and what diagnostic information would help narrow down the root cause, see below.
What the reset path does (confirmed in source)
The reset call chain ends in
InboundService.resetClientTrafficLocked(internal/web/service/inbound_traffic.go). That function:client_traffics.up = 0,down = 0,enable = truevia GORMSave.client_global_trafficsfor that email viaclearGlobalTraffic.submitTrafficWriteininternal/web/service/traffic_writer.go), which serialises against the traffic-accounting job'sAddTrafficcalls.The Xray traffic poll runs on a 5-second cadence (
cadenceXrayTrafficininternal/web/web.go). It queries Xray cumulative counters withReset_: falseand computes per-poll deltas against the in-memoryStatsLastValuesmap (internal/xray/api.go). After a reset, those deltas are added to the now-zero DB row, so at most one poll interval of new traffic accumulates before the display stabilises. That delta cannot account for a restoration of the full pre-reset total such as 25 GB.The most likely culprit for full-value restoration
The
overlayGlobalTrafficfunction (called byGetAllClientTraffics,List, andGetClientTrafficByEmail) raises displayedup/downvalues to the highest value pushed by any master panel, reading fromclient_global_traffics. It short-circuits only when that table is completely empty. If the panel was ever connected to a master panel, even if that connection has since been removed, stale rows may remain inclient_global_trafficsfor other clients, keeping the table non-empty. If a master is still actively pushing data, it would repopulate the row for the reset client on its next push, restoring the old values.Diagnostic steps to run on the server
Check whether any global-traffic rows exist in the database:
If rows are returned, the panel is receiving (or was previously receiving) traffic pushes from a master panel. Removing the master connection from the panel settings does not automatically purge these rows.
Also collect the panel service logs around the time of a reset attempt:
Please add that output to #5390 so the maintainers have the information needed to diagnose the issue.
This reply was generated automatically; a maintainer may follow up.