mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #5768] [MERGED] fix(inbounds): apply runtime changes after the DB commit #5981
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#5981
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/5768
Author: @n0ctal
Created: 7/3/2026
Status: ✅ Merged
Merged: 7/8/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-durable-first-pr-a📝 Commits (2)
fa851e8fix(inbounds): apply runtime changes after commitf610b92ci: fix staticcheck findings📊 Changes
9 files changed (+409 additions, -184 deletions)
View changed files
📝
.github/workflows/ci.yml(+33 -0)📝
internal/logger/logger.go(+4 -5)📝
internal/web/service/bulk_traffic_test.go(+1 -0)📝
internal/web/service/inbound.go(+134 -168)➕
internal/web/service/inbound_durable_postgres_test.go(+164 -0)📝
internal/web/service/node.go(+9 -3)📝
internal/web/service/node_bulk_dispatch_test.go(+62 -8)📝
internal/web/service/node_client_breakdown_test.go(+1 -0)📝
internal/web/service/node_tree_test.go(+1 -0)📄 Description
Summary
selectedsync mode by issuing a live post-commit delete, with dirty-node reconcile left as a backup.Why
The old code could apply Xray/runtime changes before the inbound database write was durably committed. If the commit failed, runtime state and database state could diverge.
During review, the first draft also had a selected-mode delete regression: marking the node dirty alone is not enough when the deleted tag is no longer in the node's selected allow-list. Reconcile intentionally does not sweep unselected tags, so the worker could keep serving a deleted inbound. This revision fixes that path directly.
Scope
AddInbound: save DB state in a checked transaction, update selected-tag allow-list in that same transaction, then apply local runtime changes after commit.UpdateInbound: save DB state in a checked serialized transaction, update selected-tag allow-list in that same transaction, then apply local runtime changes after commit.DelInbound: delete DB state in a checked transaction, mark the node dirty in that transaction, then apply node/local delete after commit.Validation
go test ./internal/web/service -run 'TestDelInbound_NodeSelectedModeDeletesRemoteImmediately|TestReconcileNode_|TestEnsureInboundTagAllowed|TestMarkNodeDirtyTxRollsBackWithTransaction|TestAddInbound_PostgresCommitFailure|TestUpdateInbound_PostgresCommitFailure' -count=1 -vgo test -race ./internal/web/service -run 'TestDelInbound_NodeSelectedModeDeletesRemoteImmediately|TestReconcileNode_SelectedModeLeavesUnselectedRemoteInbounds|TestEnsureInboundTagAllowed' -count=1 -vgo vet ./internal/web/servicegit diff --checkThe PostgreSQL commit-failure tests require
XUI_DB_TYPE=postgresandXUI_DB_DSN; without those variables they skip locally and run in the dedicated CI job.Risk
Add/Update for node-hosted inbounds now converge asynchronously through dirty-node reconcile instead of pushing the remote row inline. In normal operation this means a short propagation delay of roughly one sync interval.
Delete does not rely solely on that async path: it sends a live post-commit delete to the node so
selectedsync mode cannot leave a ghost inbound running. If the live delete fails because the node is offline, the dirty flag remains as a retry signal for the normal reconcile path.For selected-mode Add/Update, the selected-tag allow-list update is kept in the same database transaction as the inbound row. That preserves rollback semantics without reintroducing runtime side effects before commit.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.