mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6676] [Bug]: Traffic Reset Is Not Applied to Offline or Disabled Nodes, Causing Stale Traffic to Return After Reconnection #4459
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#4459
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 @mrcodebaz on GitHub (Sep 28, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6676
Describe the bug
Title
[Bug] Traffic reset is lost for disabled/offline nodes and stale traffic is restored after reconnection (v3.8.5)
Description
In a Master–Node setup, traffic reset is not reliably applied to nodes that are disabled or unreachable at the moment of reset.
Version: 3X-UI v3.8.5
Architecture: Master panel with multiple remote nodes
Clients: Same client UUID/email exists across corresponding inbounds on multiple nodes
Tests performed
Test 1 — All nodes online
0 Bon the master and all nodes.Result: Works correctly.
Test 2 — Node disabled from the master
Observed example:
The traffic generated by the active nodes was removed, but the disabled node's
76.45 MBremained. The total did not become zero.When the client starts using that node again, new traffic continues on top of the old, unreset value.
Test 3 — Node enabled but server unreachable
Observed result:
Test 4 — Traffic jump after reconnection
In another test:
After reconnecting and generating traffic, part of the stale node counter was treated as new consumption and added to the master's total.
Test 5 — Other client changes
Client configuration changes such as:
are reconciled correctly after the node reconnects.
The issue specifically affects traffic reset/accounting.
Expected behavior
When Reset Traffic is requested:
Actual behavior
Suspected affected areas
Please inspect:
Suggested fix
Implement a persistent Reset generation/epoch or pending command system:
On reconnection:
node_client_traffics.At minimum, a failed Reset request must not be silently discarded, and the first stale snapshot after reconnection must not be counted as new traffic.
Impact
This bug can cause:
How to reproduce the problem
Example observed:
91.97 MB76.45 MBinstead of0 BExpected behavior
No response
Actual behavior
No response
Relevant logs
Screenshots
No response
3x-ui version
3.8.5
Xray-core version
26.9.9
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04 LTS (GNU/Linux 6.8.0-36-generic x86_64)
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 (Sep 28, 2026):
You are right about v3.8.5, and it is already fixed on the default branch. Commit
4210a50c("fix(traffic): make a client reset reach every counter enforcing its quota") adds a persistent per-node reset queue, which is close to what you proposed. No stable release carries it yet. It is only in thedev-latestpre-release; v3.8.5 (2026-09-16) predates it.Why v3.8.5 loses the reset
Before
4210a50c,ResetClientTrafficininternal/web/service/inbound_traffic.gomade one attempt to reach the node and only logged a failure. The removed code said so directly:The commit message also notes that
BulkResetTraffic,ResetAllClientTrafficsandClientService.ResetAllTraffics"never told the node at all". A disabled or unreachable node therefore kept its old Xray counters, which is what you saw in Tests 2 and 3.What changed on main
node_pending_resetsrow for each node that hosts the client, inside the same transaction as the reset.queueNodeResetsis ininternal/web/service/node_reset_queue.go:29. It is called frominbound_traffic.go:743andclient_traffic.go:102,:193and:234. It does not filter by node enable or status, so disabled and offline nodes are queued too.deliverNodeResetsNow,node_reset_queue.go:135). If that fails, the row stays queued ("what fails stays queued for the node sync job").node_traffic_sync_job.go:322:if !n.Enable || n.Status != "online"). Once the node is enabled and back online, the queued resets are replayed before the traffic snapshot is fetched (node_traffic_sync_job.go:390-392: "Before the snapshot, so counters a reset just zeroed are what gets merged."). This is your steps 1-3.DeliverNodeResets,node_reset_queue.go:123-126, matched onqueued_atso a newer reset is kept). This is your "ACK" step.inbound_node.go:935-936:clientFrozen := lifecycleFrozen || owed). A stale node verdict therefore cannot switch the client off again.Until a release includes this, the workaround is to reset a client only while every node hosting it is enabled and online (your Test 1 path).
Verdict: Already fixed
Severity: High (traffic/quota accounting wrong on a common multi-node path)
Confidence: High
Root cause:
InboundService.ResetClientTraffic(internal/web/service/inbound_traffic.go, pre-4210a50c) sent the node reset once and dropped a failure. The bulk and reset-all paths never sent one. Nothing stored or replayed an undelivered reset, so a disabled or unreachable node kept its pre-reset counters.Already fixed:
4210a50cfix(traffic): make a client reset reach every counter enforcing its quota. On the default branch and in thedev-latestpre-release, in no stable release yet (latest is v3.8.5).Duplicate of: None
Evidence:
node_reset_queue.go:29(queue),:91-131(delivery, row dropped only after success);node_traffic_sync_job.go:390-392(replay before snapshot);inbound_node.go:550,:935-936(owed-reset freeze); testsTestNodeTrafficSyncReplaysOwedResetBeforeSnapshot(internal/web/job/node_reset_replay_test.go),TestNodeResetReplayedAfterFailure,TestNodeResetNotDeliveredDoesNotRedisableClient(internal/web/service/node_reset_undelivered_test.go).Not determined: I could not trace exactly how Test 4 turned 44 MB into 92 MB, because the jump (+48 MB) is not the full stale 76 MB. Since the fix zeroes the node counter before the first post-reconnect snapshot is merged, re-running Test 3/4 on a
dev-latestbuild is the check that settles it.This reply was generated automatically; a maintainer may follow up.