mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #6370] [Bug]: مشکل کش و کلاینت تکراری #4322
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#4322
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 @libea18 on GitHub (Aug 31, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6370
Describe the bug
مشکلی که هست:
اگر کلاینتی رو ما اد کنیم، بعد اونو بنا به هر دلیلی پاک کنیم، اگه زیر 90-120 ثانیه دوباره با همون اسم بسازیم، از اینباند آن اتچ میشه و بعد 120 ثانیه اتچ میشه
این مشکل بعضی جاها اذیت میکنه
توی 3.6.0 پاک میشه بعد 120 ثانیه اد میشه
توی 3.7.0 ان اتچ
How to reproduce the problem
مشکلی که هست:
اگر کلاینتی رو ما اد کنیم، بعد اونو بنا به هر دلیلی پاک کنیم، اگه زیر 90-120 ثانیه دوباره با همون اسم بسازیم، از اینباند آن اتچ میشه و بعد 120 ثانیه اتچ میشه
این مشکل بعضی جاها اذیت میکنه
توی 3.6.0 پاک میشه بعد 120 ثانیه اد میشه
توی 3.7.0 ان اتچ
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.04
Which parts of the panel are affected?
No response
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 (Aug 31, 2026):
بله، این باگ واقعی است و هنوز روی شاخهٔ اصلی (
f727d04f، همان v3.7.0) وجود دارد. علتش «کش» نیست: یک tombstone ۹۰ ثانیهای روی ایمیل کلاینتِ حذفشده گذاشته میشود که هنگام ساختن دوبارهٔ همان ایمیل برداشته نمیشود، و اولین merge اسنپشات نود بعد از آن، کلاینتِ تازهساخته را از اینباند detach میکند. بعد از انقضای همان ۹۰ ثانیه، merge بعدی (هر ۵ ثانیه یکبار) دوباره وصلش میکند — که دقیقاً همان «۹۰ تا ۱۲۰ ثانیه»ای است که گزارش کردهاید.یک نکته مهم: این مسیر فقط روی پنل مرکزیای اجرا میشود که حداقل یک نود (multi-node) دارد؛ فرم گزارش این را نمیپرسد. اگر پنل شما نود دارد، تحلیل زیر دقیقاً همان چیزی است که میبینید — لطفاً فقط همین یک مورد را تأیید کنید.
زنجیرهٔ اتفاق
۱. حذف کلاینت →
ClientService.Deleteبلافاصله ایمیل را tombstone میکند:۲.
withdrawClientTombstonesفقط روی مسیرهای خطا صدا زده میشود (client_crud.go:653،:693،:729وclient_bulk.go:824،:861). هیچ مسیر ساختِ کلاینت — از جملهClientService.Createدرclient_crud.go:119— tombstone را برنمیدارد. یعنی حذفِ موفق ۹۰ ثانیه tombstone زنده باقی میگذارد، حتی اگر شما ثانیهٔ بعد همان ایمیل را دوباره بسازید.۳. جاب
node_traffic_syncهر ۵ ثانیه اجرا میشود (internal/web/web.go:298→cadenceNodeTraffic = "@every 5s") و درsetRemoteTrafficLockedکلاینتهای اسنپشات را قبل از sync فیلتر میکند:۴.
SyncInboundیک sync کامل با prune است — «links for clients no longer in the set are removed» (internal/web/service/client_link.go:82-86) →reconcileInboundLinksسطرclient_inboundsرا پاک میکند (client_link.go:226-228). همینجا کلاینت detach میشود. بعدش sweep همان merge هم روی آنsync_orphaned_atمیزند (inbound_node.go:1210-1231).چرا در ۳.۶.۰ «پاک» میشد و در ۳.۷.۰ «detach» میشود
این تفاوت دقیقاً از کامیت
5bc81dfd(«fix(node): stop the node sync from deleting clients it never meant to») میآید که بین v3.6.0 و v3.7.0 مرج شده. متن خود کامیت: «"Ended the merge unattached" is true for a real remote deletion and equally true for a bad merge, so it now stampssync_orphaned_atinstead of deleting». پس مشاهدهٔ شما درست است: در ۳.۶.۰ همان merge کلاینت را hard-delete میکرد، در ۳.۷.۰ فقط detach میکند. آن کامیت tombstone را روی همهٔ مسیرهای خطای delete برمیدارد، ولی مسیر «همان ایمیل دوباره ساخته شد» را پوشش نمیدهد.سابقهٔ مشابه هم هست: کامیت
6185db58(«fix(clients): drop tombstone gate that blocked re-import after delete») قبلاً همین کلاس از مشکل را در شاخهٔ create داخلSyncInboundبرطرف کرده بود؛ گیتِ سمت اسنپشات که الان مقصر است، همانجا عمداً نگه داشته شد.راهحل موقت تا زمان رفع
بعد از حذف کلاینت، حدود ۹۰ ثانیه صبر کنید و بعد همان نام را دوباره بسازید؛ یا کلاینت را حذف نکنید و بهجایش ویرایش/غیرفعال کنید (edit بهجای delete + re-add) — چون فقط
Deleteاست که tombstone میگذارد. اگر لازم شد سریعتر آزاد شود، ریاستارت پنل (x-ui restart) هم نگاشت tombstone را که فقط در حافظه است پاک میکند.Verdict: Confirmed bug
Severity: High
Confidence: Medium
Root cause:
ClientService.Delete(internal/web/service/client_crud.go:649) sets a 90 s tombstone (internal/web/service/client_locks.go:23) that is withdrawn only on delete-failure paths (client_crud.go:653/693/729,client_bulk.go:824/861). No create path —ClientService.Create,client_crud.go:119— withdraws it, sosetRemoteTrafficLockedfilters the re-created email out of the node snapshot (internal/web/service/inbound_node.go:1147-1151) and hands the pruned list toSyncInbound(inbound_node.go:1187), which deletes theclient_inboundslink (client_link.go:82-86,:226-228) and stampssync_orphaned_at(inbound_node.go:1210-1231). Trigger: master panel with ≥1 node, client deleted and re-created with the same email inside the 90 s window; the node traffic sync runs every 5 s (internal/web/web.go:298).Already fixed: Still present on the default branch (
f727d04f= v3.7.0). Commit5bc81dfd(in v3.7.0) changed the sweep from hard-delete to detach, which is exactly the 3.6.0 → 3.7.0 difference the reporter describes, but it did not add a tombstone withdrawal on re-create.Duplicate of: None. Related: #6294 (same merge, different cause — stale
config_dirty, fixed by5bc81dfd); Related: #6356 (detach on node panels, but its cause is delete never converging to the node, not the tombstone).Evidence:
client_locks.go:23const deleteTombstoneTTL = 90 * time.Second;client_crud.go:649tombstoneClientEmail(existing.Email);inbound_node.go:1149if isClientEmailTombstoned(clients[i].Email) { continue };client_link.go:82-83"SyncInbound makes the inbound's client records and links match clients exactly: links for clients no longer in the set are removed";client_link.go:226-228prune delete;web.go:298cadenceNodeTraffic = "@every 5s"; commit5bc81dfd; precedent commit6185db58. Existing testTestFailedDeleteWithdrawsTombstone(client_delete_tombstone_test.go:12) pins withdrawal on the failure path only.Not determined: Whether the reporter's panel actually has node(s) — this is the precondition for the path above, and the bug form does not ask. Their reply naming the node count settles it; nothing else in a single-panel install reads the tombstone map.
Suggested fix: Withdraw the tombstone for an email that is legitimately re-created, i.e. call
withdrawClientTombstonesonce the newClientRecord/link is committed inClientService.Create(and the bulk-create equivalent), so a live tombstone can never outlive the identity it was meant to bury. A regression test should delete a client, re-create it with the same email, runsetRemoteTrafficLockedwith a snapshot that carries it, and assert theclient_inboundslink survives.@MHSanaei — Confirmed bug, High severity. Root cause: the 90 s delete tombstone (
internal/web/service/client_locks.go:23) is never withdrawn when the same email is re-created (ClientService.Create,internal/web/service/client_crud.go:119), so the node merge filters the re-created client out of the snapshot (internal/web/service/inbound_node.go:1147-1151) andSyncInboundprunes itsclient_inboundslink (inbound_node.go:1187). Still present onf727d04f(v3.7.0).این پاسخ بهصورت خودکار تولید شده است و ممکن است یکی از نگهدارندگان پروژه در ادامه پیگیری کند.