Repository navigation
fix(realtime): skip the project check when this pod holds no connections for it - #15168
Conversation
…ons for it Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟠 1 high 💬 Inline comments (1)
This PR short-circuits
Reviewed commit: 4292899 |
🟢 Tier S · Ready to merge
Project permission checks are skipped when a realtime pod has neither project connections nor console tails, and the project database is resolved only when a session-backed connection needs a user lookup. When verification fails, the handler now detaches local tails for that project as well as failing closed for affected connections. Latest changes: The latest commit detaches every local project tail when permission verification fails and adds a registry regression test for that cleanup.
📂 Walkthrough · 3
Reviewed the commits since |
There was a problem hiding this comment.
Adds an early-return guard in the Realtime event handler so permission-revalidation sweeps are skipped for projects with no connections on the worker.
Key findings
- 🟠 Connection guard skips tail reauthorization — Handler.php:390
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
… connections Co-Authored-By: Claude Opus 5.5 <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The findings that requested changes are resolved. See the summary comment for what is still open.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The findings that requested changes are resolved. See the summary comment for what is still open.
Issue / Description
Investigation: appwrite-labs/cloud#7179
projects.*events (transferupdate.team, project-widesessions.delete) are console events, so they are published in the console region only. On 2026-11-01 17:15:43 UTC, all three FRA realtime pods receivedprojects.protiva.update.teamfor an SGP project. Each one failed the permission check withPool 'database_db_sgp1_self_hosted_0_0' not found.The cause is
revalidateProject(). It starts the coroutine and the database check before checking whether this pod holds any connection for the project.checkProject()then resolves the project's database first, which in another region throws. FRA held noprotivaconnections (realtime.closed=0on every pod), so the check was useless there. #15086 caught the exception. Before #15086, the same event would have frozen FRA realtime.Solution
revalidateProject()returns beforeverify()when the pod holds neither connections nor console tails for the project. There is nothing to re-check, so it skips the coroutine and both database lookups.checkProject()resolves the project database lazily, only for a session or impersonator connection that needs it. Console tails are re-authorized from the project document alone, so the console region can still end a tail on a project hosted in another region without that region's pool.Not in this PR: the region that holds the project's own connections never receives these events. That is tracked in appwrite-labs/cloud#7179 (Finding 3).
Tests
HandlerTest::testSkipsTransferOfProjectWithoutConnectionsOnThisPodsends aprojects.remote.update.teamevent to a handler with no connections.verify(), runs the coroutine and database check, and the PHPUnit process dies (exit 255).no_subscriberand no failure is counted.RealtimeConsoleTailTest::testTailEndsWhenProjectIsTransferredcovers the tail path: a console tail with no project connections, then a transfer.tests/unit/Realtime: 61 tests pass.🤖 Generated with Claude Code