fix(realtime): keep boot sweep from deleting reconnected presences · appwrite/appwrite@7a16442 · GitHub
Skip to content

Commit 7a16442

Browse files
fix(realtime): keep boot sweep from deleting reconnected presences
The CE orphan sweep runs asynchronously while new connections are already accepted. A reconnect increments the same per-user row in place, which keeps its $createdAt, so the row still matched lessThan('$createdAt', $since) and was deleted despite the fresh live hold. Select candidates by $updatedAt (the field a reuse actually moves) and delete through State::deleteOrphan, which re-reads under the same forUpdate row lock the increment takes and bails when $updatedAt >= $since. Whichever grabs the lock first wins: a mid-sweep reconnect advances $updatedAt and is skipped; a sweep delete lets the reconnect create a fresh row. A live hold is never lost. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5d0b547 commit 7a16442

2 files changed

Lines changed: 47 additions & 8 deletions

File tree

‎app/realtime.php‎

Lines changed: 13 additions & 8 deletions

‎src/Appwrite/Presences/State.php‎

Lines changed: 34 additions & 0 deletions

0 commit comments

Comments
 (0)