mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5842] [CLOSED] fix: clean up node_client_traffics when deleting a client #6007
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#6007
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/5842
Author: @guocn
Created: 7/7/2026
Status: ❌ Closed
Base:
main← Head:fix/delete-node-client-traffics📝 Commits (1)
456698afix: clean up node_client_traffics when deleting a client📊 Changes
1 file changed (+6 additions, -0 deletions)
View changed files
📝
internal/web/service/client_crud.go(+6 -0)📄 Description
Summary
When a client is deleted, the
node_client_trafficstable is not cleaned up. This PR adds the missingDeletecall in bothDelete()andDeleteByEmail()code paths.Problem
Deleting a client via the panel UI or API cleans up all related tables —
client_traffics,client_global_traffic,inbound_client_ips,client_inbounds,client_external_links, the inbound settings JSON, and theClientRecordrow — butnode_client_trafficsis never touched.This means:
node_client_trafficsfor every client ever created and deleted, across every registered node.DELETE FROM node_client_traffics WHERE email = ?directly, the next node traffic sync cycle re-creates the rows — the master re-inserts orphaned traffic based on stale xray stats counters from remote nodes.Fix
Add
db.Where("email = ?", email).Delete(&model.NodeClientTraffic{})in both deletion paths, alongside the existingclient_traffics/inbound_client_ipscleanup.This ensures consistency: when
keepTraffic=false, all traffic-related tables for that email are purged, including per-node records.Changes
Testing
node_client_trafficsimmediately and permanently.keepTraffic=truepath (detach) correctly preservesnode_client_trafficsrows, same as it preservesclient_traffics.Fixes #5841
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.