[GH-ISSUE #5561] [Bug]: Central panel does not delete clients from linked inbound nodes #3882

Closed
opened 2026-10-31 20:35:37 +07:00 by bsakaguchi · 4 comments
Owner

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

  1. Install and use 3x-ui v3.4.0.
  2. Configure one panel as the central panel.
  3. Connect several remote nodes/panels to the central panel.
  4. Create a user, for example User 1.
  5. Add 3 linked inbound entries for this user on 3 different remote panels/nodes.
  6. Confirm that all 3 inbounds are successfully created on the corresponding remote panels.
  7. Open the user on the central panel.
  8. Go to the Linked Inbounds section.
  9. Remove one of the linked inbound entries.
  10. Refresh the page or wait for the next synchronization.

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

  • 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 @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 1. Install and use **3x-ui v3.4.0**. 2. Configure one panel as the central panel. 3. Connect several remote nodes/panels to the central panel. 4. Create a user, for example **User 1**. 5. Add 3 linked inbound entries for this user on 3 different remote panels/nodes. 6. Confirm that all 3 inbounds are successfully created on the corresponding remote panels. 7. Open the user on the central panel. 8. Go to the **Linked Inbounds** section. 9. Remove one of the linked inbound entries. 10. Refresh the page or wait for the next synchronization. ### 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 ```shell ``` ### 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 - [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).
bsakaguchi 2026-10-31 20:35:37 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@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}/detach with { inboundIds: [<central-inbound-id>] }. The handler (internal/web/controller/client.go, detach) calls DetachByEmailMany → Detach → DelInboundClientByEmail (internal/web/service/client_inbound_apply.go:719).

DelInboundClientByEmail does three things in order:

  1. Removes the client from the central inbound's Settings JSON and saves it to the central DB (inside a serialized transaction).
  2. Deletes the client_inbounds row that links the client to this inbound (via SyncInbound).
  3. After the transaction commits, calls rt.DeleteUser() on the remote node (internal/web/runtime/remote.go:495), which posts panel/api/clients/{email}/detach to the remote panel with the remote-side inbound ID.

On the remote panel, the same detach handler runs, removes the client from the remote inbound's Settings JSON, and updates the remote client_inbounds table.

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:

  1. Fetches a traffic snapshot from the remote panel via GET panel/api/inbounds/list (which returns the remote panel's current inbound list from its database, including the full settings JSON with the client array).
  2. Calls InboundService.SetRemoteTraffic → setRemoteTrafficLocked (internal/web/service/inbound_node.go:227).

When the node is not marked dirty, setRemoteTrafficLocked does two things that conflict with the detach:

  • It writes updates["settings"] = snapIb.Settings to the central inbound row (inbound_node.go:484), overwriting whatever the detach just saved with the snapshot from the remote panel.
  • It calls SyncInbound(tx, c.Id, filtered) (inbound_node.go:799) with the client list parsed from that same snapshot, rebuilding the client_inbounds rows 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's Settings and to client_inbounds, making the linked inbound reappear.

The subsequent ReconcileNode triggered by a dirty flag (if DeleteUser failed) reads the central inbound's settings from DB — which setRemoteTrafficLocked has 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 DeleteUser fails for any reason (transient network error, tag resolution failure, auth issue), markDirty = true is set and the node is marked dirty. However, setRemoteTrafficLocked may execute in the same sync tick with dirty = 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 DeleteUser succeeds, 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 that setRemoteTrafficLocked's snapshot-driven SyncInbound has no way to distinguish between a client that was intentionally detached and one that the remote panel still legitimately reports. The tombstoneClientEmail mechanism that guards against this for full client deletion (client_crud.go:424) is not applied for the per-inbound detach path.

Relevant source locations

  • Detach logic: internal/web/service/client_inbound_apply.go:719 (DelInboundClientByEmail) and client_crud.go:635 (Detach)
  • Remote propagation: internal/web/runtime/remote.go:495 (DeleteUser)
  • Snapshot overwrite: internal/web/service/inbound_node.go:484 (settings update) and inbound_node.go:799 (SyncInbound call)
  • Sync job: 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=debug or warning, 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.

<!-- gh-comment-id:4798312604 --> @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}/detach` with `{ inboundIds: [<central-inbound-id>] }`. The handler (`internal/web/controller/client.go`, `detach`) calls `DetachByEmailMany` → `Detach` → `DelInboundClientByEmail` (`internal/web/service/client_inbound_apply.go:719`). `DelInboundClientByEmail` does three things in order: 1. Removes the client from the central inbound's `Settings` JSON and saves it to the central DB (inside a serialized transaction). 2. Deletes the `client_inbounds` row that links the client to this inbound (via `SyncInbound`). 3. After the transaction commits, calls `rt.DeleteUser()` on the remote node (`internal/web/runtime/remote.go:495`), which posts `panel/api/clients/{email}/detach` to the remote panel with the remote-side inbound ID. On the remote panel, the same `detach` handler runs, removes the client from the remote inbound's `Settings` JSON, and updates the remote `client_inbounds` table. **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: 1. Fetches a traffic snapshot from the remote panel via `GET panel/api/inbounds/list` (which returns the remote panel's current inbound list from its database, including the full `settings` JSON with the client array). 2. Calls `InboundService.SetRemoteTraffic` → `setRemoteTrafficLocked` (`internal/web/service/inbound_node.go:227`). When the node is not marked dirty, `setRemoteTrafficLocked` does two things that conflict with the detach: - It writes `updates["settings"] = snapIb.Settings` to the central inbound row (`inbound_node.go:484`), overwriting whatever the detach just saved with the snapshot from the remote panel. - It calls `SyncInbound(tx, c.Id, filtered)` (`inbound_node.go:799`) with the client list parsed from that same snapshot, rebuilding the `client_inbounds` rows 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's `Settings` and to `client_inbounds`, making the linked inbound reappear. The subsequent `ReconcileNode` triggered by a dirty flag (if `DeleteUser` failed) reads the central inbound's settings from DB — which `setRemoteTrafficLocked` has 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 `DeleteUser` fails for any reason (transient network error, tag resolution failure, auth issue), `markDirty = true` is set and the node is marked dirty. However, `setRemoteTrafficLocked` may execute in the same sync tick with `dirty = 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 `DeleteUser` succeeds, 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 that `setRemoteTrafficLocked`'s snapshot-driven `SyncInbound` has no way to distinguish between a client that was intentionally detached and one that the remote panel still legitimately reports. The `tombstoneClientEmail` mechanism that guards against this for full client deletion (`client_crud.go:424`) is not applied for the per-inbound detach path. **Relevant source locations** - Detach logic: `internal/web/service/client_inbound_apply.go:719` (`DelInboundClientByEmail`) and `client_crud.go:635` (`Detach`) - Remote propagation: `internal/web/runtime/remote.go:495` (`DeleteUser`) - Snapshot overwrite: `internal/web/service/inbound_node.go:484` (settings update) and `inbound_node.go:799` (`SyncInbound` call) - Sync job: `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=debug` or `warning`, 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.*
Author
Owner

@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}

<!-- gh-comment-id:4798359272 --> @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}
Author
Owner

@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:

DEBUG - X-UI: Client edited onlocal:{client_name}
DEBUG - X-UI: Old client deleted onlocal:{client_name}

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_inbounds relation 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.

<!-- gh-comment-id:4798381619 --> @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: ```text DEBUG - X-UI: Client edited onlocal:{client_name} DEBUG - X-UI: Old client deleted onlocal:{client_name} ``` 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_inbounds` relation 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.
Author
Owner

@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:

  • the linked inbound is removed from the central panel;
  • it is not added back to the subscription;
  • the linked inbound association is removed on the remote panel;
  • the client object itself still remains on the remote panel, so cleanup is not complete.

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.

<!-- gh-comment-id:4798607477 --> @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: * the linked inbound is removed from the central panel; * it is not added back to the subscription; * the linked inbound association is removed on the remote panel; * the client object itself still remains on the remote panel, so cleanup is not complete. 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**.
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#3882
No description provided.