Repository navigation
Description
Problem and impact
Log and metrics reads perform external HTTP queries while holding an exclusive PostgreSQL lock on the requesting user's row and an open database transaction. A slow observability service therefore delays other operations for that account and occupies a database connection for the duration of the network request. Concurrent affected accounts can also create shared connection pressure.
Affected revision: 1295e534d7a1c3cd0a492449de8806aa532a4924. Priority: P2, transaction boundaries and degraded-service isolation.
Evidence and scenario
LogsQueries.searchcalls the external log store insideaccounts.run().MetricsQueriesdoes the same for application, node and organization metrics.AccountMutationAuthority.runexecutes the whole callback insidewithUserLock. That store method takesSELECT ... FOR UPDATEand retains the transaction until the callback finishes.- If VictoriaLogs or VictoriaMetrics stalls, another operation requiring the same account lock waits for the external read to finish or fail. These locks intentionally serialize account mutations against password resets and permission changes, so this coupling extends beyond another chart request.
The log request timeout is 10 seconds, applied to the HTTP query. This already matches the entire 10-second interactive transaction timeout, before counting authorization and resource lookup. Metrics requests have a 5-second HTTP timeout.
This also conflicts with the unit-of-work's explicit boundary rule that external network I/O happens outside the transaction.
Evidence level: verified source call chain and timeout configuration. The audit did not run a database lock-contention or production load test, and does not claim measured pool exhaustion. The store's bounded responses and finite timeouts limit individual requests but do not remove the lock coupling.
Proposed correction
Introduce an appropriate read-authority boundary: authorize the account, credential and resource in a short database operation; perform external reads outside the database transaction; then perform any live authorization recheck needed before releasing the result. Preserve current tenant filtering, API-token scope checks and revocation semantics. Keep mutation locks for operations that actually require atomic authorization and writes.
Acceptance criteria
- With a deliberately delayed fake log/metrics service, prove that the external wait retains neither an account row lock nor a database transaction/connection.
- A concurrent authorized account operation completes without waiting for that external read.
- Role removal, account invalidation and API-token revocation/scope changes during the read do not cause data to be returned contrary to the intended authorization guarantee; test the chosen revalidation contract explicitly.
- Cover application logs and application/node/organization metrics, including an upstream timeout and oversized/error responses.
- Preserve existing tenant isolation, response bounds and sanitized error behavior.
Publication check (2026-11-25): main advanced to 2ee78ff1e96118b1732b98bc54c99f5f91b95a32 through #469, which changes only an exec-session test. The production paths above are unchanged.
Activity
feat: the deployment page shows its build output, live (part of #265) (…