mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6851] [MERGED] Keep a client re-created by inbounds/add from being orphaned by a stale delete tombstone #6482
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#6482
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/6851
Author: @FZ1010
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @alireza0
Base:
main← Head:fix/readded-client-tombstone📝 Commits (1)
706f8cbWithdraw delete tombstones for clients re-created by any serialized write📊 Changes
6 files changed (+129 additions, -14 deletions)
View changed files
📝
internal/web/service/client_bulk.go(+0 -5)📝
internal/web/service/client_crud.go(+0 -3)📝
internal/web/service/client_delete_tombstone_test.go(+93 -0)📝
internal/web/service/client_link.go(+3 -0)📝
internal/web/service/client_locks.go(+12 -0)📝
internal/web/service/traffic_writer.go(+21 -6)📄 Description
Problem
On a master with a node (
inboundSyncMode: "all"), the following loses the client:POST inbounds/del/<id>for a node inbound with one client, e.g.ww-tunnel-81.POST clients/del/ww-tunnel-81, becauseinbounds/delonly detaches the client and a re-add with the same email is otherwise refused as "Duplicate email".POST inbounds/addfor the same node inbound with a client of the same email. This recreates the same tagn<node>-in-<port>-tcp.The delete in step 2 tombstones the email for 90 s (#6382).
ClientService.Createand bulk create withdraw that tombstone, butInboundService.AddInbound, which creates the client throughSyncInbound/syncInboundClients, does not. So the next node merge filters the re-created client out of the snapshot (setRemoteTrafficLocked), unlinks it from its inbound and marks it a sync orphan. Unless a later merge happens to re-link it,ReapSyncOrphanshard-deletes it 15 minutes later, and the node drops it.We hit this in production on v3.9.0 masters: one tunnel client was reaped (
reap sync orphans: removed 1 client(s)) after each of three re-adds. It reproduced on all 6 tries on two clean 3.9.0 boxes, and never with a fresh email. The code path is unchanged onmain.Fix
syncInboundClientsrecords the emails it creates on the serialized transaction's state.runSerializedTxwithdraws their tombstones only after the commit. It is still on the traffic writer, so no node merge runs between the commit and the withdrawal.CreateandbulkCreateare now covered by this path and removed, so there is one place that owns the rule.Tests
In
client_delete_tombstone_test.go:TestReaddedNodeInboundKeepsRecreatedClient: re-adds a node inbound with a just-deleted email, then merges a snapshot. The client must stay linked and must not be orphan-marked. It fails onmainand passes with the fix.TestRolledBackCreateKeepsTombstone: a create inside a serialized transaction that rolls back must leave the tombstone standing.go test ./...(50 packages),go vet ./...,gofmtandgolangci-lint(0 issues) all pass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.