mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6329] [Bug]: Selecting an existing node inbound in the central panel deletes it from the node #4297
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#4297
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 @S0rushSotoudeh on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6329
Describe the bug
When multiple nodes are connected to a central 3x-ui panel, selecting an existing node inbound from the central panel unexpectedly deletes that inbound from the node.
The inbound is created directly through the node’s own panel and works correctly. However, when I open the Nodes section in the central panel and select that inbound so it can be managed or displayed among the central panel’s inbounds, the central panel removes the inbound from the node instead.
How to reproduce the problem
Expected behavior
Selecting an existing node inbound in the central panel should import, synchronize, or display it in the central panel without deleting it from the node.
Actual behavior
The central panel deletes the selected inbound from the node instead of synchronizing or importing it.
Relevant logs
Screenshots
No response
3x-ui version
3.7.0
Xray-core version
26.7.28
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24
Which parts of the panel are affected?
Multi-node (sub-nodes)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Cloudflare (proxied DNS)
Before submitting
@github-actions[bot] commented on GitHub (Aug 25, 2026):
Confirmed — this is a real bug, and it is the remaining gap in the sweep guard that was added for #5898 and narrowed again for #6283. Selecting an existing node inbound in Selected inbounds mode makes the master delete it from the node, because the delete sweep runs before the import that would have created the central row.
What actually happens
Saving the node form writes
inbound_tagsand marks the node config-dirty in the same transaction —internal/web/service/node.go:585andinternal/web/service/node.go:592:On the next 5 s traffic-sync tick,
syncOnereconciles the dirty node first and only then pulls the snapshot that would import the inbound —internal/web/job/node_traffic_sync_job.go:367and:390:Inside
ReconcileNode,desiredTagsis built only from inbounds already in the master DB (internal/web/service/inbound_node.go:96→Where("node_id = ?", nodeID), then:113). Your newly created node-side inbound has no central row yet, so its tag is absent fromdesiredTags. The sweep then reads a selected-but-unimported tag as "the master deleted this" —internal/web/service/inbound_node.go:181-192:Remote.DelInboundpostspanel/api/inbounds/del/<id>to the node (internal/web/runtime/remote.go:437), so the inbound and its clients are gone on the node. The import path that would have created the central row (internal/web/service/inbound_node.go:693,tx.Create(&newIb)) never gets the chance — by the time the snapshot is fetched the inbound no longer exists.Why the existing guard does not catch it
The
#5898fix (200ea091) only skips the sweep before the node's first adoption —internal/web/service/inbound_node.go:167:Your node has already synced once, so
inbounds_adopted_atis non-zero and the gate is open. Note that upgrading also seeds every pre-existing node as adopted (seedNodeInboundsAdopted,internal/database/db.go:1327), so any node that was already connected is in this state. The#6283follow-up (a255ab7c) only stopped the flag being stamped by a sync that adopted nothing; it did not cover a tag selected later, which #6283 itself called out ("any tag selected later is swept because the master holds no inbound under it").Both fixes are in v3.7.0 (
git tag --contains 200ea091/a255ab7c→v3.7.0), and the sweep loop above is unchanged on the default branch, so this is still present at the tip.The Load inbounds from node button is read-only and does not import anything —
POST /panel/api/nodes/inbounds(internal/web/controller/node.go:41) callsGetRemoteInboundOptions(internal/web/service/node.go:698), which only fills the tag picker. Selecting an entry marks the tag master-owned while the master holds no matching inbound, which is exactly the state the sweep destroys.Workaround until this is fixed
Do not create the inbound on the node and then select it. Create it from the central panel with the node chosen as its target: that path stores the central row and adds the tag to the node's selection in the same transaction (
EnsureInboundTagAllowedTx,internal/web/service/inbound.go:1125), so the sweep always sees it as desired.Switching the node to All inbounds is not a safe alternative here — saving the node still marks it dirty, and with
selected == nilthe sweep deletes every remote tag missing from the master DB, including the new one.Verdict: Confirmed bug
Severity: High
Confidence: High
Root cause:
InboundService.ReconcileNode,internal/web/service/inbound_node.go:181-192. Inselectedsync mode the delete sweep treats a tag that is inNode.InboundTagsbut has noinboundsrow withnode_id = <node>as "deleted on the master" and callsrt.DelInbound. It cannot distinguish "the panel deleted it while the node was offline" from "the operator just selected it and it has not been imported yet". Triggering condition:n.InboundsAdoptedAt != 0(any node that has synced once, or any node seeded on upgrade byseedNodeInboundsAdopted,internal/database/db.go:1327) +InboundSyncMode == "selected"+ a tag added toInboundTagsfor an inbound that exists only on the node. Introduced by554d85c2("feat: allow selecting inbounds synchronized from nodes (#5178)"), which added the selected-mode carve-out; the guard added in200ea091covers only the pre-adoption case.Already fixed: Still present on the default branch —
internal/web/service/inbound_node.go:181-192is unchanged at HEAD (f727d04f).200ea091(#5898) anda255ab7c(#6283) are both already in v3.7.0 and neither covers this path.Duplicate of: None. Related: #5898 (same sweep, pre-adoption case, fixed by
200ea091) and #6283 (same sweep, empty-tag-list onboarding case, fixed bya255ab7c) — this is the third uncovered entry point into the same delete loop.Evidence:
internal/web/service/node.go:585,592— saving the node writesinbound_tagsand callsMarkNodeDirtyTxin one transaction.internal/web/job/node_traffic_sync_job.go:367-390—ReconcileNoderuns beforeFetchTrafficSnapshot, so the delete precedes the import in the same tick.internal/web/service/inbound_node.go:96,113—desiredTagsis built only from rows already in the master DB.internal/web/service/inbound_node.go:167—if n.InboundsAdoptedAt == 0 { return ... }, the only sweep guard.internal/web/service/inbound_node.go:190—rt.DelInbound(ctx, &model.Inbound{Tag: tag});internal/web/runtime/remote.go:437postspanel/api/inbounds/del/<id>to the node.internal/web/service/inbound_node.go:693— the adoption path (tx.Create(&newIb)) that would have created the central row.internal/web/service/node.go:698-713+internal/web/controller/node.go:41— "Load inbounds from node" is read-only.TestReconcileNode_SelectedModeLeavesUnselectedRemoteInbounds(internal/web/service/inbound_node_reconcile_test.go:101) andTestReconcileNode_SkipsSweepBeforeFirstAdoption(:151). Nothing pins a selected but not yet imported tag, which is why this passes CI.Not determined: Whether this node was onboarded in
selectedmode or switched to it fromall— the outcome is the same in both, so it does not change the verdict. A successful sweep delete logs nothing on the master (only the failure path atinternal/web/service/inbound_node.go:191does), so the single check that would confirm this exact path on the reporter's instance is the node's access log showingPOST /<basePath>/panel/api/inbounds/del/<id>arriving from the master within ~5 s of saving the node form.Suggested fix: The sweep needs to distinguish "selected and previously imported" from "selected and not imported yet" — a tag the master has never held a row for is a pending import, not a deletion. One option is to skip the delete for a selected tag that has no central row and no deletion tombstone, leaving it for the snapshot merge to adopt on the same tick; another is to make selecting a tag import it synchronously so the central row exists before the node is marked dirty.
@MHSanaei
This reply was generated automatically; a maintainer may follow up.