mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6181] [MERGED] fix(clients): push bulk client changes to nodes only after the commit lands #6143
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#6143
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/6181
Author: @n0ctal
Created: 8/8/2026
Status: ✅ Merged
Merged: 8/14/2026
Merged by: @MHSanaei
Base:
main← Head:upstream-node-push-after-commit📝 Commits (5)
0503192fix(clients): apply bulk mutations after durable commit876b25etest(clients): guard bulk pushes behind commit92beaf9Merge branch 'main' into upstream-node-push-after-commitdea1fb2fix(clients): fully delete remote bulk clientsc12acefMerge branch 'main' into upstream-node-push-after-commit📊 Changes
2 files changed (+136 additions, -90 deletions)
View changed files
📝
internal/web/service/client_bulk.go(+50 -90)📝
internal/web/service/node_bulk_dispatch_test.go(+86 -0)📄 Description
Summary
Move the node-side client push in
bulkAdjustInboundClientsandbulkDelInboundClientsso it runs after the database transaction commits, and let the existing dirty-node reconcile converge instead of pushing eagerly.Why
Both bulk paths pushed the mutated client set to the remote node before
runSerializedTxwrote the inbound. If that transaction then failed — a serialization retry giving up, a constraint violation, the traffic poll holding the lock — the node had already applied changes the panel never recorded.From that point the two disagree, and they disagree silently: the node serves expiry and quota values that exist nowhere in the database, while the panel believes the operation did not happen. Nothing marks the divergence, because each half individually reported success. It surfaces later as a client whose limits do not match the panel, with no event to trace it back to.
This is an ordering bug rather than a race — the push is unconditionally sequenced before the write, so no amount of retrying changes the outcome.
Scope
bulkAdjustInboundClients: drop the pre-commit push block and push after a successful commit, keeping the existingflowChangedandnodeBulkPushThresholdconditions unchanged.bulkDelInboundClients: same reordering. The deletion path now runs throughrunSerializedTxwithMarkNodeDirtyTx, so a push that fails converges through reconcile instead of leaving the node ahead of the panel.prevSettings/advancePushedInboundbookkeeping that existed only to compensate for the early push.Validation
go build ./internal/...clean.go test ./internal/web/service/green onmainatece16559with this applied.mainwithout conflict.TestNodeBulkAdjustDoesNotPushBeforeFailedCommitandTestNodeBulkDeleteDoesNotPushBeforeFailedCommitfail the transaction and assert the node received nothing.internal/web/service/client_bulk.goreverted toece16559, they fail withfailed transaction pushed 1 UpdateUser call(s) to the node, want 0andfailed transaction pushed 1 delete call(s) to the node, want 0— so they guard the ordering itself, not the refactor.go test -race ./internal/web/service/,go vetandmake gen-checkclean.Risk
Low. A failed push now leaves the node marked dirty and is picked up by the existing reconcile pass rather than retried inline — the same mechanism that already covers batches above
nodeBulkPushThresholdand flow changes. No schema, API, or configuration change.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.