Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Presence Cleanup in Housekeeping Process #602

Closed
chacha912 opened this issue Aug 7, 2023 · 0 comments · Fixed by #1036
Closed

Handle Presence Cleanup in Housekeeping Process #602

chacha912 opened this issue Aug 7, 2023 · 0 comments · Fixed by #1036
Assignees
Labels
cleanup 🧹 Paying off technical debt enhancement 🌟 New feature or request

Comments

@chacha912
Copy link
Contributor

Description:

When a document is explicitly detached, the presence is removed from the presences through PresenceChange{type: 'clear'}. This helps keep snapshot presence lightweight. However, when the client does not explicitly invoke detach, there is an issue that the presence not to be cleared.

Currently, during housekeeping, the document state is updated using clientInfo.DetachDocument(). It is also necessary to clear the presence at this point.

for _, clientInfo := range candidates {
if _, err := clients.Deactivate(
ctx,
h.database,
clientInfo.ProjectID,
clientInfo.ID,
); err != nil {

if err := clientInfo.DetachDocument(id); err != nil {
return nil, err
}
// TODO(hackerwins): We need to remove the presence of the client from the document.
// Be careful that housekeeping is executed by the leader. And documents are sharded
// by the servers in the cluster. So, we need to consider the case where the leader is
// not the same as the server that handles the document.

Why:
To prevent continuous growth of the presence snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup 🧹 Paying off technical debt enhancement 🌟 New feature or request
Projects
Status: Done
Status: Todo
3 participants