[GH-ISSUE #7093] [Bug]: Resetting all client traffic can hide new group usage #6616

Open
opened 2026-11-07 14:33:32 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @BenjaminMitchell-D0FB on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/7093

Describe the bug

Reset all client traffic clears client counters without shifting group baselines. A group can lose previously counted usage and suppress subsequent usage until its clients catch up to the stale baseline.

How to reproduce the problem

  1. Generate about 500 MB of download traffic through the client.
  2. Reset traffic for the group from Groups. Confirm the group shows zero while the client still has its original usage.
  3. In Clients, run Reset all client traffic.
  4. Generate about 50 MB of new download traffic and wait until the Clients page counts it.
  5. Refresh Groups and compare its download total with the newly counted download.

Expected behavior

The group download total increases by the new usage. Resetting client counters preserves the group accounting period, as it does for individual and selected-client resets.

Actual behavior

Client download shows about 50 MB, but the group remains at zero because its download baseline still holds about 500 MB. The display only starts to increase after the new cumulative download exceeds that baseline.

Relevant logs


Screenshots

No response

3x-ui version

3.11.0

Xray-core version

v26.10.21

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Statistics / traffic counters

Browser (only if it is a UI bug)

Chrome

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 @BenjaminMitchell-D0FB on GitHub (Nov 7, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/7093 ### Describe the bug Reset all client traffic clears client counters without shifting group baselines. A group can lose previously counted usage and suppress subsequent usage until its clients catch up to the stale baseline. ### How to reproduce the problem 1. Generate about 500 MB of download traffic through the client. 2. Reset traffic for the group from Groups. Confirm the group shows zero while the client still has its original usage. 3. In Clients, run Reset all client traffic. 4. Generate about 50 MB of new download traffic and wait until the Clients page counts it. 5. Refresh Groups and compare its download total with the newly counted download. ### Expected behavior The group download total increases by the new usage. Resetting client counters preserves the group accounting period, as it does for individual and selected-client resets. ### Actual behavior Client download shows about 50 MB, but the group remains at zero because its download baseline still holds about 500 MB. The display only starts to increase after the new cumulative download exceeds that baseline. ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.11.0 ### Xray-core version v26.10.21 ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Statistics / traffic counters ### Browser (only if it is a UI bug) Chrome ### 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).
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

This is a real bug, and it is still present on the default branch. Clients → Reset all client traffic is the only client-reset path that zeroes client_traffics without moving the group reset baselines. So the stale baseline gets subtracted from the new usage, and the group shows 0 until the clients' new cumulative traffic passes it.

Why it happens

The Groups page shows each group's live sum of client_traffics minus its stored baseline (internal/web/service/client_groups.go:54-55):

up := max(clampedTrafficAdd(agg.up, -baseUp[name]), 0)
down := max(clampedTrafficAdd(agg.down, -baseDown[name]), 0)

To keep that difference stable, every reset first shifts the baseline down by the counters it is about to zero. It calls adjustGroupBaselinesForRemovedTraffic (client_groups.go:64-68, added in 1153d5db "fix(groups): keep group traffic totals stable across client resets and deletes", for #5675). It is called from:

  • single-client reset: internal/web/service/inbound_traffic.go:682 and :790
  • selected-clients reset: internal/web/service/client_traffic.go:101
  • per-inbound reset-all: internal/web/service/client_traffic.go:202
  • client delete / removal: client_crud.go:1081, client_bulk.go:991, inbound_traffic.go:646,659

ClientService.ResetAllTraffics (internal/web/service/client_traffic.go:241-282) never makes that call. It goes straight to zeroClientTraffics(tx, nil, keepOff) at line 255. This is the handler for POST /panel/api/clients/resetAllTraffics (internal/web/controller/client.go:77, :365), which the Clients page calls (frontend/src/hooks/useClients.ts:527). In your steps: the group reset stores a ~500 MB ResetDown; reset-all zeroes the client but leaves ResetDown alone; 50 MB of new download then shows as max(50 − 500, 0) = 0.

It also breaks a group that was never reset. Its baseline is 0, so reset-all wipes the whole accumulated group total, which is the #5675 symptom again on this one path.

Workaround until it is fixed: after a global Reset all client traffic, run Reset traffic on each affected group from the Groups page. That recomputes the baseline from the current (now small) counters, and the group counts up normally from there. The group's usage from before the reset is not recovered. Resetting clients by selection, or per inbound, keeps group totals correct.

Verdict:        Confirmed bug
Severity:       Medium
Confidence:     High
Root cause:     internal/web/service/client_traffic.go:241-266, ClientService.ResetAllTraffics
                zeroes every client_traffics row (line 255) without first calling
                adjustGroupBaselinesForRemovedTraffic, so client_groups.reset_up/reset_down
                keep the pre-reset counters. 1153d5db added the call to every other reset
                path but missed this one.
Same class:     None found. All other zeroClientTraffics callers (client_traffic.go:104, :206;
                inbound_traffic.go:689) and the delete paths shift the baseline first.
                InboundService.ResetAllTraffics (inbound_traffic.go:881-892) touches only
                inbound up/down, which groups do not read.
Already fixed:  Still present on the default branch (e535df03) and in v3.11.0.
Duplicate of:   Related: #5675 (same invariant, fixed for every other path in 1153d5db)
Evidence:       client_groups.go:54-55 (display = live sum − baseline);
                client_groups.go:455-462 (live sum read from client_traffics);
                client_traffic.go:202 (per-inbound reset-all adjusts) vs client_traffic.go:245-266
                (global reset-all does not); client_group_reset_test.go has
                TestGroupTotalsSurviveSingleClientReset / ...BulkClientReset / ...ClientDelete
                but no test for ClientService.ResetAllTraffics.
Not determined: None.

Suggested fix: in ClientService.ResetAllTraffics, shift every group's baseline down by its current counters inside the same transaction, before zeroClientTraffics. That is what resetAllClientTrafficsLocked already does for one inbound. Because emails is nil here, the call needs either the full email list or a variant of shiftGroupBaselines that sums over all grouped clients. A regression test next to TestGroupTotalsSurviveBulkClientReset that calls ResetAllTraffics would cover it.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:6699380542 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): This is a real bug, and it is still present on the default branch. **Clients → Reset all client traffic** is the only client-reset path that zeroes `client_traffics` without moving the group reset baselines. So the stale baseline gets subtracted from the new usage, and the group shows 0 until the clients' new cumulative traffic passes it. **Why it happens** The Groups page shows each group's live sum of `client_traffics` minus its stored baseline (`internal/web/service/client_groups.go:54-55`): ```go up := max(clampedTrafficAdd(agg.up, -baseUp[name]), 0) down := max(clampedTrafficAdd(agg.down, -baseDown[name]), 0) ``` To keep that difference stable, every reset first shifts the baseline down by the counters it is about to zero. It calls `adjustGroupBaselinesForRemovedTraffic` (`client_groups.go:64-68`, added in `1153d5db` "fix(groups): keep group traffic totals stable across client resets and deletes", for #5675). It is called from: - single-client reset: `internal/web/service/inbound_traffic.go:682` and `:790` - selected-clients reset: `internal/web/service/client_traffic.go:101` - per-inbound reset-all: `internal/web/service/client_traffic.go:202` - client delete / removal: `client_crud.go:1081`, `client_bulk.go:991`, `inbound_traffic.go:646,659` `ClientService.ResetAllTraffics` (`internal/web/service/client_traffic.go:241-282`) never makes that call. It goes straight to `zeroClientTraffics(tx, nil, keepOff)` at line 255. This is the handler for `POST /panel/api/clients/resetAllTraffics` (`internal/web/controller/client.go:77`, `:365`), which the Clients page calls (`frontend/src/hooks/useClients.ts:527`). In your steps: the group reset stores a ~500 MB `ResetDown`; reset-all zeroes the client but leaves `ResetDown` alone; 50 MB of new download then shows as `max(50 − 500, 0) = 0`. It also breaks a group that was never reset. Its baseline is 0, so reset-all wipes the whole accumulated group total, which is the #5675 symptom again on this one path. **Workaround until it is fixed:** after a global **Reset all client traffic**, run **Reset traffic** on each affected group from the Groups page. That recomputes the baseline from the current (now small) counters, and the group counts up normally from there. The group's usage from before the reset is not recovered. Resetting clients by selection, or per inbound, keeps group totals correct. ``` Verdict: Confirmed bug Severity: Medium Confidence: High Root cause: internal/web/service/client_traffic.go:241-266, ClientService.ResetAllTraffics zeroes every client_traffics row (line 255) without first calling adjustGroupBaselinesForRemovedTraffic, so client_groups.reset_up/reset_down keep the pre-reset counters. 1153d5db added the call to every other reset path but missed this one. Same class: None found. All other zeroClientTraffics callers (client_traffic.go:104, :206; inbound_traffic.go:689) and the delete paths shift the baseline first. InboundService.ResetAllTraffics (inbound_traffic.go:881-892) touches only inbound up/down, which groups do not read. Already fixed: Still present on the default branch (e535df03) and in v3.11.0. Duplicate of: Related: #5675 (same invariant, fixed for every other path in 1153d5db) Evidence: client_groups.go:54-55 (display = live sum − baseline); client_groups.go:455-462 (live sum read from client_traffics); client_traffic.go:202 (per-inbound reset-all adjusts) vs client_traffic.go:245-266 (global reset-all does not); client_group_reset_test.go has TestGroupTotalsSurviveSingleClientReset / ...BulkClientReset / ...ClientDelete but no test for ClientService.ResetAllTraffics. Not determined: None. ``` Suggested fix: in `ClientService.ResetAllTraffics`, shift every group's baseline down by its current counters inside the same transaction, before `zeroClientTraffics`. That is what `resetAllClientTrafficsLocked` already does for one inbound. Because `emails` is nil here, the call needs either the full email list or a variant of `shiftGroupBaselines` that sums over all grouped clients. A regression test next to `TestGroupTotalsSurviveBulkClientReset` that calls `ResetAllTraffics` would cover it. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
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#6616
No description provided.