mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6401] [Bug]: adding a node that already holds an inbound/client identical to the master's removes them instead of merging #4337
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#4337
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 @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
@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.tagis globally unique —internal/database/model/model.go:68: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:Only if both forms are taken is adoption skipped, and then it says so (
:702-707):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), andTestSetRemoteTraffic_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.emailis globally unique —internal/database/model/model.go:918: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 fromSyncInbound,: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-latestonly). 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):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
ReconcileNodetreats a selected tag with no central row as "the master deleted this" —internal/web/service/inbound_node.go:183-192:and
Remote.DelInboundpostspanel/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 byif 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
Selectedmode and ticked the copied tag, your report is #6329 and I would close this as a duplicate; if you usedAll(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
All inboundsorSelected? This is the single fact that separates the confirmed bug #6329 from an unknown one.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".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)
applyClientRecordMergeviaClientService.SyncInbound(internal/web/service/client_link.go:22-80,84) lets a node overwrite a master-owned client record becauseClientRecord.Emailis the only key (internal/database/model/model.go:918) — fixed on main bya31fa9ab, unreleased; (b) theReconcileNodedelete sweep (internal/web/service/inbound_node.go:183-192) inselectedmode, which is #6329. Trigger for (b):InboundsAdoptedAt != 0+InboundSyncMode == "selected"+ a selected tag with noinboundsrow for that node.Already fixed: Partially.
a31fa9ab(duplicate client email) is on the default branch only —git merge-base --is-ancestor a31fa9ab v3.7.0fails,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—pickFreeTagfalls back to then<id>-alias;:700-709— skip + warning when both forms are taken.internal/web/service/inbound_node.go:119-131andinternal/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— addsclientEmailsOwnedElsewhere(internal/web/service/inbound_node.go:417-455), applied at:1229-1251, plusTestNodeCannotClaimClientOfAnotherInbound(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 thepanel/api/inbounds/del/<id>call behind #6329.internal/web/service/node.go:421-423andfrontend/src/pages/nodes/NodeFormModal.tsx:53—allis the default sync mode, so #6329's path is not the default one.Not determined: Whether the reporter's node uses
selectedsync 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 atinternal/web/service/inbound_node.go:193logs), so the node's access log showingPOST /<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.