perf(traffic): find globally depleted clients with one set query (#7021)

On a node that a master pushes cross-panel usage to, the 5-second traffic job looked up client_global_traffics once per enabled client to decide who to disable, and its freshness probe counted every fresh row (#7008).

The scan of all enabled clients now builds the over-quota ids once and matches them with IN, and the probe is an EXISTS that stops at the first fresh row. Who gets disabled is unchanged: same 24-hour window, one master must reach the quota, masters are never summed. The email-scoped callers keep the correlated predicate. The Postgres job runs the four semantic tests.
This commit is contained in:
Hamed
2026-11-24 14:52:53 +03:30
committed by GitHub
parent 3a27c1c169
commit 4b36cc1635
5 changed files with 249 additions and 22 deletions
+10
View File
@@ -114,6 +114,16 @@ jobs:
exit 1
fi
- name: PostgreSQL depletion query regressions
run: |
set -o pipefail
go test ./internal/web/service -run '^TestDepletionQuery(Semantics|FreshnessAndReset|ConcurrentCommit|Renewals)$' -count=1 -v | tee /tmp/postgres-depletion-query.log
passed=$(grep -c -- '^--- PASS' /tmp/postgres-depletion-query.log || true)
if [ "$passed" -ne 4 ]; then
echo "expected 4 passing PostgreSQL depletion tests, got $passed" >&2
exit 1
fi
- name: PostgreSQL deferred-commit test
run: |
set -o pipefail