3x-ui/internal
MHSanaei f8b72de995 fix(node-sync): write only changed client rows in the node traffic merge
Every 5s node merge rewrote one client_traffics row and one
node_client_traffics baseline per (inbound, client) pair the node
reported, even when nothing had moved: a client is reported once per
inbound it is on, and idle clients every tick. On top of that each
inbound's SyncInbound wrote its own per-inbound values onto the shared
clients record, so a client on a flow and a non-flow inbound (or on a
WireGuard tunnel plus any other inbound) had its record flipped back
and forth twice per merge. With 7 nodes and ~20k client links that is
tens of thousands of statements per tick, all inside transactions on
the single serialized writer, holding row locks for seconds. A renew
of a client on 38 inbounds takes one writer turn per inbound, queued
behind those merges each time, and outlived the 30s HTTP write timeout
even though it committed; last_sub_fetch updates waited on the same
locks.

The merge now computes the row its UPDATE would leave, mirroring the
SQL merge expressions, and skips the write when nothing changes; the
baseline upsert is skipped when the node counter has not moved. The
record's per-inbound fields get one owner each, so repeated syncs
agree: flow is settled to the effective flow (lowest-id link carrying
one) for clients whose links changed, and WireGuard/AmneziaWG peer
fields come from the client's lowest-id tunnel. A repeated unchanged
snapshot now writes no client row; one active client writes two.

Verified beyond make verify: the CI Postgres lane, the merge and flow
tests run against PostgreSQL 16, and make node-e2e.

Closes #6815
2026-10-14 00:37:00 +02:00
..
amneziawg fix(amneziawg): bound S1-S3 by the receive buffer, reject overlapping H (#6642) 2026-09-26 22:02:49 +02:00
amneziawgnet fix(amneziawg): respect tunnel MTU when writing UDP replies (#6780) 2026-10-12 03:11:09 +02:00
config v3.10.0 2026-10-12 16:43:44 +02:00
crypto/nodetoken fix(nodetoken): stop refusing every node-token key file on Windows 2026-09-27 15:55:42 +02:00
database fix(database): blank boolean-era verifyPeerCertByName values on hosts 2026-10-12 18:16:22 +02:00
eventbus chore: refresh dependencies, fix Linux tool tasks, modernize Go idioms 2026-07-25 16:08:09 +02:00
logger fix(logger): reuse the open log rotator when InitLogger runs again 2026-09-27 15:32:20 +02:00
mtproto fix(mtproto): synchronize child-process lifecycle (#6141) 2026-07-29 20:56:26 +02:00
nodee2e chore(nodes): run the master+node scopes in parallel and document both layers 2026-10-05 13:30:18 +02:00
pia chore(build): bump Go toolchain to 1.27.0 2026-08-23 21:57:03 +02:00
sub fix(sub): isolate Incy subscription routing from Happ headers (#6810) 2026-10-13 16:01:32 +02:00
testpg test(database): give each package its own schema when tests run on PostgreSQL (#6594) 2026-09-26 21:13:42 +02:00
tuic fix(clients): balance renewal form layout and mode guidance (#6672) 2026-10-08 21:59:38 +02:00
tunnelmonitor style: adopt golangci-lint v2 and resolve all findings 2026-06-27 15:42:22 +02:00
util perf: reduce traffic formatter allocations (#6790) 2026-10-12 11:05:40 +02:00
web fix(node-sync): write only changed client rows in the node traffic merge 2026-10-14 00:37:00 +02:00
xray fix(xray): fall back to the userspace TUN where kernel TUN cannot be set up 2026-10-12 17:52:45 +02:00