mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #6612] [MERGED] fix(ip-limit): CAS-retry inbound_client_ips merges under Postgres #6378
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#6378
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/6612
Author: @mrchatam
Created: 9/19/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei
Base:
main← Head:fix/inbound-client-ips-lost-update📝 Commits (4)
96b72b0fix(ip-limit): CAS-retry inbound_client_ips merges under Postgres6feb41eci: retrigger frontend after npm registry maintenanceda86a60Merge branch 'main' into fix/inbound-client-ips-lost-update59a1c24test(ip-limit): cover the scan's CAS against a mid-scan node sync📊 Changes
4 files changed (+266 additions, -44 deletions)
View changed files
➕
internal/web/job/check_client_ip_cas_test.go(+64 -0)📝
internal/web/job/check_client_ip_job.go(+45 -30)📝
internal/web/service/inbound_client_ips.go(+48 -14)📝
internal/web/service/inbound_client_ips_merge_test.go(+109 -0)📄 Description
Summary
Fixes a PostgreSQL lost-update race on
inbound_client_ips.ipsthat defeats cluster-wide IP limits (#6587).MergeInboundClientIpsandcheck_client_ip_jobboth read-modify-write the same JSON blob. On SQLite (_txlock=immediate) writers cannot interleave; on Postgres at READ COMMITTED they can, and the loser drops remote addresses thatpartitionLiveIpsonly counts via that blob (the 120s cross-node liveness window).The issue author listed three shapes and asked for design agreement first; with no maintainer consensus yet, this takes the smallest fix that matches the repo's existing atomic-update pattern (conditional
Where+RowsAffected, as inNodeServiceapi_token /config_dirty_atCAS): compare-and-set on the previous blob, re-read and re-merge on miss. No serialization of the writers, no schema migration.Changes
CasUpdateInboundClientIps+mergeExistingClientIpsCAS loop inMergeInboundClientIpsupdateInboundClientIpsuses the same CAS; ban side effects run only after the blob write succeeds (or is a no-op), so a lost CAS cannot advancebannedSeenTest plan
go test ./internal/web/service/ -run 'TestMergeInboundClientIps|TestCasUpdateInboundClientIps|TestPruneStaleClientIps'go test ./internal/web/job/go vet ./internal/web/service/ ./internal/web/job/Fixes #6587
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.