perf(traffic): skip unchanged client lifecycle writes (#7204)

A full inbound save ran the lifecycle UPDATE on client_traffics for every client of the inbound, even when quota, expiry, renewal settings and the enable flag already matched. On PostgreSQL each of those is a new row version and WAL, on every stream-settings edit of a large inbound.

Guard the same UPDATE with a NULL-safe IS DISTINCT FROM over the eight columns it assigns, so the database writes only a row that actually differs and still repairs one that drifted. The PostgreSQL CI job runs the lifecycle suite, including a row-lock check on a second connection.

Closes #7202
This commit is contained in:
Hamed
2026-11-25 15:23:19 +03:30
committed by GitHub
parent 64ca67706f
commit efb6c6d579
5 changed files with 480 additions and 5 deletions
+9
View File
@@ -84,6 +84,15 @@ jobs:
exit 1
fi
- name: PostgreSQL client traffic lifecycle edits
run: |
set -o pipefail
go test ./internal/web/service -run '^TestClientTrafficLifecyclePostgres$' -count=1 -v | tee /tmp/postgres-client-traffic-lifecycle.log
if ! grep -q -- '^--- PASS: TestClientTrafficLifecyclePostgres ' /tmp/postgres-client-traffic-lifecycle.log; then
echo "expected the PostgreSQL client traffic lifecycle suite to pass" >&2
exit 1
fi
- name: PostgreSQL batched stats identities
run: |
set -o pipefail