mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5561] [Bug]: Central panel does not delete clients from linked inbound nodes #3882
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#3882
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 @mrtruefel on GitHub (Jun 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5561
Describe the bug
Version
3x-ui: v3.4.0
Description
When using a central 3x-ui panel connected to multiple remote nodes/panels, deleting linked inbound entries for a client does not work correctly.
Adding linked inbounds works as expected: when a user has multiple inbounds assigned to different remote panels, they are created successfully on the target panels.
However, when removing one of the linked inbounds through the Linked Inbounds section on the central panel, the entry is removed only temporarily from the central panel UI. The corresponding client/inbound is not deleted from the remote panel. After a short refresh or synchronization, the removed entry appears again on the central panel.
As a result, the central panel can add clients to remote panels, but it cannot properly remove them. This makes centralized client management unreliable or effectively unusable.
How to reproduce the problem
Expected behavior
When a linked inbound is removed from a client through the central panel:
the linked entry should be removed from the central panel;
the corresponding client/inbound should also be deleted from the target remote panel;
after refresh or synchronization, the removed linked inbound should not appear again.
Actual behavior
The linked inbound disappears from the central panel only temporarily.
The client/inbound is not deleted from the remote panel.
After a short refresh or synchronization, the linked inbound appears again on the central panel.
The central panel can add clients to remote panels, but cannot remove them correctly.
Example
There is User 1 with 3 linked inbounds:
inbound 1 on panel/node 1;
inbound 2 on panel/node 2;
inbound 3 on panel/node 3.
All three linked inbounds are added successfully through the central panel and appear correctly on their respective remote panels.
If one linked inbound is removed through the Linked Inbounds section on the central panel, it temporarily disappears from the central panel UI. However, it is not removed from the remote panel. After refresh/synchronization, the central panel pulls the data from the remote node again and restores the previously removed linked inbound.
Impact
This bug prevents proper centralized client management.
Currently, the central panel can be used to add clients to remote panels, but it cannot reliably delete clients from them. This causes data desynchronization and requires manual removal directly on each remote panel.
Possible cause
It seems that when a linked inbound is removed on the central panel, the delete request is either not sent to the target remote panel or is not executed there. During the next synchronization, the central panel reads the still-existing client from the remote panel and restores the deleted linked inbound.
Suggested fix
When removing a linked inbound from the central panel:
Send a delete request to the corresponding remote panel/node.
Verify that the client/inbound was successfully removed on the remote panel.
Remove the linked inbound from the central panel only after successful deletion.
Prevent the central panel from restoring intentionally deleted linked inbounds during the next synchronization.
Actual behavior
The linked inbound disappears from the central panel only temporarily.
The client/inbound is not deleted from the remote panel.
After a short refresh or synchronization, the linked inbound appears again on the central panel.
The central panel can add clients to remote panels, but cannot remove them correctly.
Relevant logs
Screenshots
No response
3x-ui version
3.4.0
Xray-core version
26.2.2
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Backend (API endpoints, login, settings)
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 25, 2026):
The report is reproducible against the v3.4.0 source. Here is what the code actually does and where it breaks.
How the detach is supposed to work
When a linked inbound is removed from a client on the central panel, the UI calls
POST /panel/api/clients/{email}/detachwith{ inboundIds: [<central-inbound-id>] }. The handler (internal/web/controller/client.go,detach) callsDetachByEmailMany→Detach→DelInboundClientByEmail(internal/web/service/client_inbound_apply.go:719).DelInboundClientByEmaildoes three things in order:SettingsJSON and saves it to the central DB (inside a serialized transaction).client_inboundsrow that links the client to this inbound (viaSyncInbound).rt.DeleteUser()on the remote node (internal/web/runtime/remote.go:495), which postspanel/api/clients/{email}/detachto the remote panel with the remote-side inbound ID.On the remote panel, the same
detachhandler runs, removes the client from the remote inbound'sSettingsJSON, and updates the remoteclient_inboundstable.Where the race occurs
The node traffic sync job (
internal/web/job/node_traffic_sync_job.go,syncOne) runs on its own goroutine roughly every five seconds. It:GET panel/api/inbounds/list(which returns the remote panel's current inbound list from its database, including the fullsettingsJSON with the client array).InboundService.SetRemoteTraffic→setRemoteTrafficLocked(internal/web/service/inbound_node.go:227).When the node is not marked dirty,
setRemoteTrafficLockeddoes two things that conflict with the detach:updates["settings"] = snapIb.Settingsto the central inbound row (inbound_node.go:484), overwriting whatever the detach just saved with the snapshot from the remote panel.SyncInbound(tx, c.Id, filtered)(inbound_node.go:799) with the client list parsed from that same snapshot, rebuilding theclient_inboundsrows from scratch.If the snapshot was fetched from the remote panel before
rt.DeleteUser()completed there, or before the remote panel committed the change, the snapshot still contains the client. Both overwrites then restore the client to the central inbound'sSettingsand toclient_inbounds, making the linked inbound reappear.The subsequent
ReconcileNodetriggered by a dirty flag (ifDeleteUserfailed) reads the central inbound's settings from DB — whichsetRemoteTrafficLockedhas now restored to include the client — and pushes those restored settings back to the remote panel. The state is permanently stuck.Why this is consistent rather than a one-time flicker
If
DeleteUserfails for any reason (transient network error, tag resolution failure, auth issue),markDirty = trueis set and the node is marked dirty. However,setRemoteTrafficLockedmay execute in the same sync tick withdirty = false(the flag had not yet been read, or the snapshot was already in flight), restoring the client on the central side. The subsequent dirty-path reconcile then re-propagates the now-restored settings back to the remote panel, completing the loop: the client is back on both sides.Even when
DeleteUsersucceeds, the five-second polling interval and the absence of any "detach intent" marker means a single snapshot race is enough to trigger the same restore cycle.What is not happening
The detach request IS being sent to the remote panel (confirmed in
client_inbound_apply.go:859). The missing piece is thatsetRemoteTrafficLocked's snapshot-drivenSyncInboundhas no way to distinguish between a client that was intentionally detached and one that the remote panel still legitimately reports. ThetombstoneClientEmailmechanism that guards against this for full client deletion (client_crud.go:424) is not applied for the per-inbound detach path.Relevant source locations
internal/web/service/client_inbound_apply.go:719(DelInboundClientByEmail) andclient_crud.go:635(Detach)internal/web/runtime/remote.go:495(DeleteUser)internal/web/service/inbound_node.go:484(settings update) andinbound_node.go:799(SyncInboundcall)internal/web/job/node_traffic_sync_job.go:321(syncOne)Additional information that would help
If you have access to the central panel logs with
XUI_LOG_LEVEL=debugorwarning, any line matching"Error in deleting client on"or"remote DeleteUser"immediately after performing a detach would confirm whether the remote-side API call is returning an error.This reply was generated automatically; a maintainer may follow up.
@mrtruefel commented on GitHub (Jun 25, 2026):
2026/06/25 10:38:10 DEBUG - X-UI: Client edited onlocal:{name_client}
2026/06/25 10:38:10 DEBUG - X-UI: Old client deleted onlocal:{name_client}
@mrtruefel commented on GitHub (Jun 25, 2026):
Our assumption is that this issue may be caused by a race condition between the detach operation and the background node traffic sync job.
The detach request appears to be sent to the remote panel, and the remote panel logs show that the client is edited/deleted locally:
However, since the sync job runs approximately every 5 seconds, it may fetch an outdated snapshot from the remote panel while the detach operation is still in progress or before the remote state is fully committed.
If that snapshot still contains the client, the central panel may overwrite its local inbound settings and recreate the
client_inboundsrelation from the stale remote data. After that, the next reconciliation may propagate the restored state back to the remote panel, which makes the client appear again on both sides.So it looks like the problem is not that the detach request is never sent, but that the sync logic has no protection against restoring a client that was intentionally detached. A tombstone/deletion-intent marker for per-inbound detach operations could probably prevent the sync job from re-adding the client from an outdated snapshot.
@mrtruefel commented on GitHub (Jun 25, 2026):
Additional version comparison:
I also tested this behavior on earlier versions.
In v3.3.0, the behavior is at least partially usable as a workaround:
However, from the subscription/access management perspective, v3.3.0 is usable because the removed inbound does not reappear and is no longer delivered to the user.
The problem appears to start from v3.3.1. Starting with v3.3.1 and continuing in v3.4.0, removing a linked inbound from the central panel is no longer reliable: the removed inbound may be restored after synchronization, which makes this workflow unusable for centralized client management.
So this may be a regression introduced in v3.3.1.