[GH-ISSUE #6401] [Bug]: adding a node that already holds an inbound/client identical to the master's removes them instead of merging #4337

Closed
opened 2026-10-31 20:38:56 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @khorshidt1 on GitHub (Sep 3, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6401

Describe the bug

If you add a new node server and the second server already has a client or inbounds that are identical, if you try to make an inbound with the same characteristics on the main server those existing entries are removed and not replaced with the new inbound. The same applies to identical clients on the main server. In other words, the system does not overwrite; it deletes the original entries and does not add the new ones.

How to reproduce the problem

Simply copy the inbound to a new server, then add that server as a node to the main server. The copied data will be removed, and it will not be replaced with new data when you request a new inbound from the main server.

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.7.0

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24

Which parts of the panel are affected?

Database / migrations

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 @khorshidt1 on GitHub (Sep 3, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6401 ### Describe the bug If you add a **new node server** and the second server already has a **client or inbounds that are identical**, if you try to make an inbound with the same characteristics on the main server **those existing entries are removed and not replaced with the new inbound**. The same applies to identical clients on the main server. In other words, **the system does not overwrite; it deletes the original entries and does not add the new ones.** ### How to reproduce the problem Simply copy the inbound to a new server, then add that server as a node to the main server. The copied data will be removed, and it will not be replaced with new data when you request a new inbound from the main server. ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.7.0 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24 ### Which parts of the panel are affected? Database / migrations ### 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:38:56 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 3, 2026):

I could not reproduce the deletion you describe from the code on a node added with the default inbound-sync mode, but I did confirm what the master does with a duplicate inbound tag and with a duplicate client email — and one of those two is a real defect on 3.7.0. I need three details to tell which of them you hit.

Only one commit has touched the node-sync files since v3.7.0 (git log --oneline v3.7.0..HEAD -- internal/web/service/inbound_node.go internal/web/job/node_traffic_sync_job.go internal/web/runtime/remote.go → a31fa9ab), so apart from that commit the logic below is exactly what your 3.7.0 runs; line numbers are from the current default branch.

An identical inbound tag is aliased, not dropped

inbounds.tag is globally unique — internal/database/model/model.go:68:

Tag string `json:"tag" form:"tag" gorm:"unique" example:"in-443-tcp"`

So when the master imports ("adopts") a node inbound whose tag a master inbound already owns, it retries under an n<nodeId>- alias — internal/web/service/inbound_node.go:678-684:

pickFreeTag := func() (string, error) {
    candidates := []string{snapIb.Tag}
    if prefix != "" && !strings.HasPrefix(snapIb.Tag, prefix) {
        candidates = append(candidates, prefix+snapIb.Tag)
    }

Only if both forms are taken is adoption skipped, and then it says so (:702-707):

setRemoteTraffic: tag "…" from node N collides with an existing inbound even after the nN- prefix — skipping (rename one side to remove the duplicate)

When the alias is used, both the delete sweep and the push translate between the prefixed and bare form (internal/web/service/inbound_node.go:119-131, internal/web/runtime/remote.go:328-340), and TestSetRemoteTraffic_KeepsInboundOnPrefixMismatch (internal/web/service/node_tag_sync_test.go:16) pins that. So an identical tag on its own should not get your copied inbound deleted from the node.

An identical client email is a real problem on 3.7.0

clients.email is globally unique — internal/database/model/model.go:918:

Email string `json:"email" gorm:"uniqueIndex;not null"`

On v3.7.0 the node's reported client is resolved by email alone and merged onto whatever record already holds that email (applyClientRecordMerge, internal/web/service/client_link.go:22-80, called from SyncInbound, :84). A node reporting an email that belongs to a master inbound therefore overwrites that client's UUID/password, and the master then rebuilds its own Xray config with the node-supplied credential — the original user stops working, which can easily read as "the client was removed".

That was fixed on the default branch on 2026-09-03 by a31fa9ab "fix(node): refuse a node's claim on another inbound's client". It is not in any release (git tag --contains a31fa9ab → dev-latest only). After it, the colliding client is simply not adopted onto the node inbound and the master logs (internal/web/service/inbound_node.go:1243-1246):

setRemoteTraffic: node N reported client "…", which is attached only to inbounds of another node — not adopting (rename one side to remove the duplicate email)

pinned by TestNodeCannotClaimClientOfAnotherInbound (internal/web/service/node_foreign_client_test.go:24). Either way, the practical rule is the same: the same email must not exist on two panels the master manages.

The one confirmed path that really does delete an inbound from the node

That is #6329 (open, still present at HEAD), and it needs Inbound sync = Selected on the node. There the delete sweep in ReconcileNode treats a selected tag with no central row as "the master deleted this" — internal/web/service/inbound_node.go:183-192:

for _, tag := range remoteTags {
	if _, want := desiredTags[tag]; want {
		continue
	}
	if selected != nil {
		if _, managed := selected[tag]; !managed {
			continue
		}
	}
	if err := rt.DelInbound(ctx, &model.Inbound{Tag: tag}); err != nil {

and Remote.DelInbound posts panel/api/inbounds/del/<id> to the node (internal/web/runtime/remote.go:437), so the inbound and its clients are gone there. The sweep is gated by if n.InboundsAdoptedAt == 0 { return … } (:169), i.e. it only opens after the node has synced once — which matches "add the node, then it disappears later".

If you onboarded in Selected mode and ticked the copied tag, your report is #6329 and I would close this as a duplicate; if you used All (the default — internal/web/service/node.go:421-423, frontend/src/pages/nodes/NodeFormModal.tsx:53), it is something I have not been able to locate and the logs below would find it.

What I still need

  1. The node's "Inbound sync" setting — All inbounds or Selected? This is the single fact that separates the confirmed bug #6329 from an unknown one.
  2. Master panel log from around the moment it happened, as text (journalctl -u x-ui --since "-1h" | grep -Ei 'setRemoteTraffic|reconcile|node traffic sync'). The three warnings quoted above are exactly what distinguishes "tag collision, skipped", "client not adopted" and "inbound removed centrally".
  3. What existed where, precisely: was the copied inbound present on both panels or only on the node, and were the tag and the client email byte-identical on both? Redact the UUIDs; the tag and the email prefix are enough.

Meanwhile

Do not pre-copy an inbound onto a server and then attach it as a node. Create the inbound from the central panel with the node selected as its target — that path writes the central row and the node's tag allow-list in one transaction (EnsureInboundTagAllowedTx, internal/web/service/inbound.go:1125), so neither the tag collision nor the sweep can trigger. If you must keep an existing node-side inbound, rename its tag and its client emails so they do not collide with the master's before you add the node.

I also retitled this issue for searchability — the old title was "conjoining two servers with mutual inbounds."; it still describes your problem, just in the words the code uses.

Verdict: Insufficient information
Severity: N/A — pending the sync mode and the master log
Confidence: Medium (High on what the code does with duplicate tags/emails; the deletion you report is unconfirmed)
Root cause: Not established for the reported symptom. Two confirmed adjacent causes: (a) applyClientRecordMerge via ClientService.SyncInbound (internal/web/service/client_link.go:22-80,84) lets a node overwrite a master-owned client record because ClientRecord.Email is the only key (internal/database/model/model.go:918) — fixed on main by a31fa9ab, unreleased; (b) the ReconcileNode delete sweep (internal/web/service/inbound_node.go:183-192) in selected mode, which is #6329. Trigger for (b): InboundsAdoptedAt != 0 + InboundSyncMode == "selected" + a selected tag with no inbounds row for that node.
Already fixed: Partially. a31fa9ab (duplicate client email) is on the default branch only — git merge-base --is-ancestor a31fa9ab v3.7.0 fails, git tag --contains a31fa9ab → dev-latest. The #6329 sweep is still present at HEAD (13e87a18).
Duplicate of: None yet. Related: #6329 (same "removed from the node" symptom, confirmed, selected-mode sweep), #6283 and #5898 (earlier entry points into the same sweep, both fixed in v3.7.0).
Evidence:

  • internal/database/model/model.go:68 — Tag string ... gorm:"unique"; :918 — Email string ... gorm:"uniqueIndex;not null".
  • internal/web/service/inbound_node.go:678-684 — pickFreeTag falls back to the n<id>- alias; :700-709 — skip + warning when both forms are taken.
  • internal/web/service/inbound_node.go:119-131 and internal/web/runtime/remote.go:328-340 — prefixed and bare tag forms are treated as the same inbound, so an aliased adoption is not swept.
  • internal/web/service/node_tag_sync_test.go:16 — TestSetRemoteTraffic_KeepsInboundOnPrefixMismatch.
  • internal/web/service/client_link.go:84-86 → syncInboundClients → :142-152 — the incoming client is matched by email alone and merged onto the existing record.
  • a31fa9ab — adds clientEmailsOwnedElsewhere (internal/web/service/inbound_node.go:417-455), applied at :1229-1251, plus TestNodeCannotClaimClientOfAnotherInbound (internal/web/service/node_foreign_client_test.go:24).
  • internal/web/service/inbound_node.go:169,183-192 + internal/web/runtime/remote.go:431-442 — the sweep and the panel/api/inbounds/del/<id> call behind #6329.
  • internal/web/service/node.go:421-423 and frontend/src/pages/nodes/NodeFormModal.tsx:53 — all is the default sync mode, so #6329's path is not the default one.
    Not determined: Whether the reporter's node uses selected sync mode, and whether the inbound was actually deleted on the node or merely stopped being manageable from the master. The master log lines listed in question 2 settle both — a successful sweep delete is silent on the master (only the failure branch at internal/web/service/inbound_node.go:193 logs), so the node's access log showing POST /<basePath>/panel/api/inbounds/del/<id> from the master would confirm the #6329 path outright.

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

<!-- gh-comment-id:5531530595 --> @github-actions[bot] commented on GitHub (Sep 3, 2026): I could not reproduce the deletion you describe from the code on a node added with the **default** inbound-sync mode, but I did confirm what the master does with a duplicate inbound tag and with a duplicate client email — and one of those two is a real defect on 3.7.0. I need three details to tell which of them you hit. Only one commit has touched the node-sync files since `v3.7.0` (`git log --oneline v3.7.0..HEAD -- internal/web/service/inbound_node.go internal/web/job/node_traffic_sync_job.go internal/web/runtime/remote.go` → `a31fa9ab`), so apart from that commit the logic below is exactly what your 3.7.0 runs; line numbers are from the current default branch. ## An identical inbound *tag* is aliased, not dropped `inbounds.tag` is globally unique — `internal/database/model/model.go:68`: ```go Tag string `json:"tag" form:"tag" gorm:"unique" example:"in-443-tcp"` ``` So when the master imports ("adopts") a node inbound whose tag a master inbound already owns, it retries under an `n<nodeId>-` alias — `internal/web/service/inbound_node.go:678-684`: ```go pickFreeTag := func() (string, error) { candidates := []string{snapIb.Tag} if prefix != "" && !strings.HasPrefix(snapIb.Tag, prefix) { candidates = append(candidates, prefix+snapIb.Tag) } ``` Only if **both** forms are taken is adoption skipped, and then it says so (`:702-707`): > `setRemoteTraffic: tag "…" from node N collides with an existing inbound even after the nN- prefix — skipping (rename one side to remove the duplicate)` When the alias *is* used, both the delete sweep and the push translate between the prefixed and bare form (`internal/web/service/inbound_node.go:119-131`, `internal/web/runtime/remote.go:328-340`), and `TestSetRemoteTraffic_KeepsInboundOnPrefixMismatch` (`internal/web/service/node_tag_sync_test.go:16`) pins that. So an identical tag on its own should not get your copied inbound deleted from the node. ## An identical client *email* is a real problem on 3.7.0 `clients.email` is globally unique — `internal/database/model/model.go:918`: ```go Email string `json:"email" gorm:"uniqueIndex;not null"` ``` On v3.7.0 the node's reported client is resolved by email alone and merged onto whatever record already holds that email (`applyClientRecordMerge`, `internal/web/service/client_link.go:22-80`, called from `SyncInbound`, `:84`). A node reporting an email that belongs to a **master** inbound therefore overwrites that client's UUID/password, and the master then rebuilds its own Xray config with the node-supplied credential — the original user stops working, which can easily read as "the client was removed". That was fixed on the default branch on 2026-09-03 by `a31fa9ab` *"fix(node): refuse a node's claim on another inbound's client"*. It is **not in any release** (`git tag --contains a31fa9ab` → `dev-latest` only). After it, the colliding client is simply not adopted onto the node inbound and the master logs (`internal/web/service/inbound_node.go:1243-1246`): > `setRemoteTraffic: node N reported client "…", which is attached only to inbounds of another node — not adopting (rename one side to remove the duplicate email)` pinned by `TestNodeCannotClaimClientOfAnotherInbound` (`internal/web/service/node_foreign_client_test.go:24`). Either way, the practical rule is the same: **the same email must not exist on two panels the master manages.** ## The one confirmed path that really does delete an inbound *from the node* That is #6329 (open, still present at HEAD), and it needs **Inbound sync = Selected** on the node. There the delete sweep in `ReconcileNode` treats a selected tag with no central row as "the master deleted this" — `internal/web/service/inbound_node.go:183-192`: ```go for _, tag := range remoteTags { if _, want := desiredTags[tag]; want { continue } if selected != nil { if _, managed := selected[tag]; !managed { continue } } if err := rt.DelInbound(ctx, &model.Inbound{Tag: tag}); err != nil { ``` and `Remote.DelInbound` posts `panel/api/inbounds/del/<id>` to the node (`internal/web/runtime/remote.go:437`), so the inbound and its clients are gone there. The sweep is gated by `if n.InboundsAdoptedAt == 0 { return … }` (`:169`), i.e. it only opens after the node has synced once — which matches "add the node, then it disappears later". If you onboarded in `Selected` mode and ticked the copied tag, your report is #6329 and I would close this as a duplicate; if you used `All` (the default — `internal/web/service/node.go:421-423`, `frontend/src/pages/nodes/NodeFormModal.tsx:53`), it is something I have not been able to locate and the logs below would find it. ## What I still need 1. **The node's "Inbound sync" setting** — `All inbounds` or `Selected`? This is the single fact that separates the confirmed bug #6329 from an unknown one. 2. **Master panel log** from around the moment it happened, as text (`journalctl -u x-ui --since "-1h" | grep -Ei 'setRemoteTraffic|reconcile|node traffic sync'`). The three warnings quoted above are exactly what distinguishes "tag collision, skipped", "client not adopted" and "inbound removed centrally". 3. **What existed where, precisely**: was the copied inbound present on *both* panels or only on the node, and were the tag and the client email byte-identical on both? Redact the UUIDs; the tag and the email prefix are enough. ## Meanwhile Do not pre-copy an inbound onto a server and then attach it as a node. Create the inbound **from the central panel with the node selected as its target** — that path writes the central row and the node's tag allow-list in one transaction (`EnsureInboundTagAllowedTx`, `internal/web/service/inbound.go:1125`), so neither the tag collision nor the sweep can trigger. If you must keep an existing node-side inbound, rename its tag and its client emails so they do not collide with the master's before you add the node. I also retitled this issue for searchability — the old title was *"conjoining two servers with mutual inbounds."*; it still describes your problem, just in the words the code uses. Verdict: Insufficient information Severity: N/A — pending the sync mode and the master log Confidence: Medium (High on what the code does with duplicate tags/emails; the deletion you report is unconfirmed) Root cause: Not established for the reported symptom. Two confirmed adjacent causes: (a) `applyClientRecordMerge` via `ClientService.SyncInbound` (`internal/web/service/client_link.go:22-80,84`) lets a node overwrite a master-owned client record because `ClientRecord.Email` is the only key (`internal/database/model/model.go:918`) — fixed on main by `a31fa9ab`, unreleased; (b) the `ReconcileNode` delete sweep (`internal/web/service/inbound_node.go:183-192`) in `selected` mode, which is #6329. Trigger for (b): `InboundsAdoptedAt != 0` + `InboundSyncMode == "selected"` + a selected tag with no `inbounds` row for that node. Already fixed: Partially. `a31fa9ab` (duplicate client email) is on the default branch only — `git merge-base --is-ancestor a31fa9ab v3.7.0` fails, `git tag --contains a31fa9ab` → `dev-latest`. The #6329 sweep is still present at HEAD (`13e87a18`). Duplicate of: None yet. Related: #6329 (same "removed from the node" symptom, confirmed, selected-mode sweep), #6283 and #5898 (earlier entry points into the same sweep, both fixed in v3.7.0). Evidence: - `internal/database/model/model.go:68` — `Tag string ... gorm:"unique"`; `:918` — `Email string ... gorm:"uniqueIndex;not null"`. - `internal/web/service/inbound_node.go:678-684` — `pickFreeTag` falls back to the `n<id>-` alias; `:700-709` — skip + warning when both forms are taken. - `internal/web/service/inbound_node.go:119-131` and `internal/web/runtime/remote.go:328-340` — prefixed and bare tag forms are treated as the same inbound, so an aliased adoption is not swept. - `internal/web/service/node_tag_sync_test.go:16` — `TestSetRemoteTraffic_KeepsInboundOnPrefixMismatch`. - `internal/web/service/client_link.go:84-86` → `syncInboundClients` → `:142-152` — the incoming client is matched by email alone and merged onto the existing record. - `a31fa9ab` — adds `clientEmailsOwnedElsewhere` (`internal/web/service/inbound_node.go:417-455`), applied at `:1229-1251`, plus `TestNodeCannotClaimClientOfAnotherInbound` (`internal/web/service/node_foreign_client_test.go:24`). - `internal/web/service/inbound_node.go:169,183-192` + `internal/web/runtime/remote.go:431-442` — the sweep and the `panel/api/inbounds/del/<id>` call behind #6329. - `internal/web/service/node.go:421-423` and `frontend/src/pages/nodes/NodeFormModal.tsx:53` — `all` is the default sync mode, so #6329's path is not the default one. Not determined: Whether the reporter's node uses `selected` sync mode, and whether the inbound was actually deleted on the node or merely stopped being manageable from the master. The master log lines listed in question 2 settle both — a successful sweep delete is silent on the master (only the failure branch at `internal/web/service/inbound_node.go:193` logs), so the node's access log showing `POST /<basePath>/panel/api/inbounds/del/<id>` from the master would confirm the #6329 path outright. *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#4337
No description provided.