perf(nodes): deduplicate client ownership scope rows

Deduplicate the composite (client_id, node_id) projection in clientLinkScopes before transferring ownership rows to Go. Preserve nullable master ownership, the inner join, 400-ID batching, transaction error propagation and the existing shared, foreign and detached claim semantics.

Add deterministic ownership and high-fanout regression tests for SQLite and PostgreSQL, explicitly gate both tests in PostgreSQL CI, and provide an A/B benchmark. The reported 7,101-client PostgreSQL fixture reduces returned rows from 115,041 to 31,384 and lookup time from 214.13 to 88.69 ms with 18 queries unchanged.

No database migration, cache policy or node protocol changes. All 12 pre-merge CI jobs passed. Broader sync tail latency remains a separate follow-up.

Fixes #7294
This commit is contained in:
Hamed
2026-12-04 01:08:18 +03:30
committed by GitHub
parent b7998cb334
commit 7af6fd4d9d
3 changed files with 264 additions and 1 deletions
+9
View File
@@ -312,6 +312,15 @@ jobs:
exit 1
fi
- name: PostgreSQL node client ownership scopes
run: |
set -o pipefail
test "$XUI_DB_TYPE" = postgres
test -n "$XUI_DB_DSN"
go test ./internal/web/service -run '^TestClientLinkScopes(HighFanout)?$' -count=1 -v | tee /tmp/postgres-client-link-scopes.log
grep -q '^--- PASS: TestClientLinkScopes ' /tmp/postgres-client-link-scopes.log
grep -q '^--- PASS: TestClientLinkScopesHighFanout ' /tmp/postgres-client-link-scopes.log
- name: PostgreSQL node snapshot regressions
run: |
set -o pipefail