mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6200] [MERGED] fix(traffic): apply maintenance side effects only after the commit lands #6165
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#6165
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/6200
Author: @n0ctal
Created: 8/10/2026
Status: ✅ Merged
Merged: 8/14/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-traffic-after-commit📝 Commits (3)
7f33e4afix(traffic): apply maintenance after durable commit1b331f1fix(traffic): apply all runtime maintenance after commita4de417Merge branch 'main' into upstream-traffic-after-commit📊 Changes
11 files changed (+525 additions, -311 deletions)
View changed files
📝
frontend/src/generated/types.ts(+1 -0)📝
frontend/src/generated/zod.ts(+3 -0)📝
internal/web/service/global_traffic_test.go(+5 -5)📝
internal/web/service/inbound.go(+0 -1)📝
internal/web/service/inbound_autorenew_shadowsocks_test.go(+1 -1)📝
internal/web/service/inbound_autorenew_test.go(+1 -1)📝
internal/web/service/inbound_disable.go(+46 -97)📝
internal/web/service/inbound_node.go(+22 -0)📝
internal/web/service/inbound_traffic.go(+255 -206)➕
internal/web/service/inbound_traffic_apply.go(+105 -0)➕
internal/web/service/traffic_runtime_apply_test.go(+86 -0)📄 Description
Summary
Move traffic-maintenance side effects out of the transaction bodies into a single post-commit batch, so a best-effort maintenance failure can no longer roll back usage that was already accepted.
This is the largest patch in this group. The size is deliberate: the point is the reordering, and a partial reordering would leave the two halves inconsistent.
Why
Traffic accounting and the maintenance that follows it — auto-renew, disabling depleted or expired clients, marking nodes dirty — run inside the same transaction, with runtime side effects issued from within it.
Two consequences:
Scope
Validation
go test ./...green; targeted-raceforAddTraffic,AutoRenew,DisableInvalidandGlobalTraffic.Not proven: crash injection between the first and second transaction was not performed against a real PostgreSQL. The semantics of that window are intentional — usage is durable and maintenance is retried on the next cycle — but the window itself was reasoned about rather than provoked.
Risk
Medium, because of size rather than mechanism. There is no schema or API change. Reviewing the two transaction boundaries and the post-commit batch is the whole of it; I am happy to split it further if you would rather see it in pieces.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.