Repository navigation
Mqtt subscriber cleanup revoke - #14952
Conversation
|
Review complete. 🟡 1 medium 💬 Inline comments (1)
🧹 Nitpicks (1) — 🟢 1 low
This PR integrates MQTT revocation into the delete pipeline:
Reviewed commit: 9422936 |
🟢 Tier S · Ready to mergeCleanup revokes live MQTT topic subscriptions when target deletion removes a user's final push subscription, with bulk cleanup deduplicating and batching the remaining-membership checks. Account and team claim flows revoke credentials and invalidate sessions while preserving MFA requirements, and user deletion also clears related presence, usage, and monitor state. Regression tests cover MQTT cleanup and worker deletion setup. Latest changes: The latest commits replace per-pair subscriber lookups with chunked, paginated checks, capture the MQTT adapter in the team-claim transaction, and add coverage for cross-pair matches and later-page rows.
📂 Walkthrough · 8
Reviewed the commits since |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
There was a problem hiding this comment.
The PR threads an MQTT adapter through the Deletes worker so subscriber-row deletions revoke MQTT topic subscriptions, but it adds a per-row findOne recheck for every provider type and repeats revokeTopic publishes per subscriber row.
Key findings
- 🟡 Per-subscriber recheck
findOneruns for every provider type — Targets.php:66
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…rity/mqtt-subscriber-cleanup-revoke # Conflicts: # app/controllers/api/account.php # src/Appwrite/Platform/Modules/Account/Http/Account/Sessions/IdToken/Create.php # src/Appwrite/Utopia/Database/Documents/User.php
| foreach ($toRevoke as [$userId, $topicInternalId, $topicId]) { | ||
| self::revokeIfNoLongerSubscribed($database, $mqtt, $projectId, $userId, $topicInternalId, $topicId); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Drop the user's live MQTT subscription once they hold no other subscriber row for the topic, | ||
| * matching the subscribe gate (membership is per user, not per target). Mirrors the explicit | ||
| * subscriber-delete endpoint's own notification, which this cleanup path otherwise lacks. | ||
| */ | ||
| private static function revokeIfNoLongerSubscribed(Database $database, Mqtt $mqtt, string $projectId, string $userId, string $topicInternalId, string $topicId): void | ||
| { | ||
| $stillSubscribed = $database->skipFilters(fn () => $database->findOne('subscribers', [ | ||
| Query::equal('topicInternalId', [$topicInternalId]), | ||
| Query::equal('userId', [$userId]), | ||
| ]), APP_TOPICS_SUBQUERIES); | ||
|
|
||
| if (!$stillSubscribed->isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| $mqtt->revokeTopic($projectId, $userId, $topicId); | ||
| } catch (\Throwable $error) { | ||
| Console::error('Failed to unsubscribe MQTT connection: ' . $error->getMessage()); | ||
| } | ||
| } |
There was a problem hiding this comment.
cant we bulk fetch from db and send the events instead of n+1 findone
What does this PR do?
(Provide a description of what this PR does and why it's needed.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist