mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #4299] [CLOSED] fix(multi-node): scope tag and email unique constraints per node #5644
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#5644
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/4299
Author: @abdalrahmanx9
Created: 5/12/2026
Status: ❌ Closed
Base:
main← Head:fix/node-tag-unique-scope📝 Commits (9)
686ca1ffix(multi-node): scope tag and email unique constraints per node821e50dfix(inbound): prevent shared client_traffic row deletion when sibling inbound is deleted41faaa2Merge branch 'main' into fix/node-tag-unique-scopedd18130Merge branch 'main' into fix/node-tag-unique-scope341eb5bchore(xray): minor cleanups to graceful-shutdown follow-ups for #42594ec84cfMerge branch 'main' into fix/node-tag-unique-scopeb8adda0Merge branch 'main' into fix/node-tag-unique-scope05b24bdUpdate db.go3463aeeMerge branch 'main' into fix/node-tag-unique-scope📊 Changes
7 files changed (+110 additions, -25 deletions)
View changed files
📝
database/db.go(+52 -0)📝
database/model/model.go(+7 -2)📝
web/service/inbound.go(+37 -10)📝
web/service/port_conflict.go(+10 -5)📝
xray/client_traffic.go(+2 -2)📝
xray/process.go(+0 -4)📝
xray/process_test.go(+2 -2)📄 Description
Problem
When running a central panel with multiple remote nodes, the traffic sync silently drops inbounds from some nodes. The server log shows:
Two global UNIQUE constraints are responsible:
inbounds.tag(gorm:"unique") -- if Node A has an inbound on port 48055 (tag =inbound-48055), Node B cannot sync its inbound on the same port. The tag must be globally unique, even though each node runs a separate xray instance.client_traffics.email(gorm:"unique") -- if Node A has a client with emailfoo@bar, and Node B also has a client with that email, the client stats CREATE fails and rolls back the entire transaction -- including all inbounds that were successfully created in the same cycle. The node stays at 0 inbounds permanently, retrying every 10s and failing each time.Root cause
Tags and client emails only need to be unique within the same xray instance. A tag like
inbound-48055on Node A is a completely different xray socket frominbound-48055on Node B -- they are on different machines. The same applies to client emails.Changes
4 files, +67/-9
database/model/model.go: ChangedTagfromgorm:"unique"(global) touniqueIndex:idx_node_tagcomposited withNodeID.xray/client_traffic.go: ChangedEmailfromgorm:"unique"(global) touniqueIndex:idx_ct_inbound_emailcomposited withInboundId.web/service/port_conflict.go:tagExists()scopes bynode_idso the UI does not see remote tags as conflicts.database/db.go: AddedmigrateLegacyUniqueConstraints()that removes old UNIQUE constraints from existing databases on startup and creates the new composite indexes.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.