perf(nodes): scope expiry repair to activated clients (#7241)

Every node snapshot merge ran a table-wide UPDATE that copies a node-activated deadline onto client records still holding the start-after-first-use duration, whether or not that snapshot activated anyone.

A merge now repairs only the clients it activated or renewed in that tick, and a snapshot with no such transition issues no UPDATE. Older drift (legacy imports, a tick whose client reconciliation was skipped) is repaired by the five-minute maintenance job in windows of 4,000 client ids, which also covers standalone panels. A failed repair now fails the merge on SQLite as it always did on PostgreSQL, where the transaction was already aborted.

Verified on SQLite and PostgreSQL 18: the previous code rewrites an unrelated client's expiry on every merge, and without the scoped lift a record on a tick that cannot rebuild client records keeps its negative duration.

Fixes #7233
This commit is contained in:
Hamed
2026-11-29 18:12:13 +03:30
committed by GitHub
parent b1cec64b18
commit be2a2e9e71
4 changed files with 174 additions and 13 deletions
+1 -1
View File
@@ -418,7 +418,7 @@ All registered in `web.go` → `startTask()`. Each is a struct with a `Run()` me
| `@every 10s` | `mtproto_job` | Reconcile `mtg` sidecars against enabled MTProto inbounds |
| `@every 10s` | `amneziawg_job` | Reconcile embedded AmneziaWG interfaces against enabled local inbounds |
| `@every 5m` | `outbound_subscription_job` | Refresh outbound provider configs |
| `@every 5m` | `reap_sync_orphans_job` | Delete sync-orphaned clients, then the history of emails no client holds |
| `@every 5m` | `reap_sync_orphans_job` | Repair legacy activation expiries, then reap sync orphans and unowned history |
| `@every 10m` | `clear_logs_job` (`PruneXrayLogsJob`) | Truncate Xray access/error logs once either exceeds 64 MiB |
| `@hourly` | `warp_ip_job`, `periodic_traffic_reset_job("hourly")` | WARP IP rotation; traffic resets |
| `@daily` | `clear_logs_job`, `periodic_traffic_reset_job("daily")`, `periodic_traffic_reset_job("monthly")` | IP-limit and Xray access/error log cleanup; daily resets and due monthly resets |