yorkie-team / yorkie

Yorkie is a document store for collaborative applications.
https://yorkie.dev
Apache License 2.0
761 stars 140 forks source link

Provide a notification when client is deactivated due to housekeeping #928

Closed chacha912 closed 1 month ago

chacha912 commented 3 months ago

Description:

When a client leaves a document without properly deactivating(detaching), it remains as a zombie client, leading to inefficiencies in garbage collection. To address this issue, server deactivates clients that have been inactive for a certain period through a housekeeping process.

The default Client Deactivate Threshold is set to 24 hours, meaning that if a client has not edited the document for 24 hours, it will be deactivated and no longer considered to be participating in document editing.

However, there are cases where a user leaves a document open for a long time without actively editing it, causing housekeeping to occur and disconnecting the user from document editing. In such cases, users should be notified that the document has been disconnected and instructed to re-attach in order to continue editing.

Considerations:

chacha912 commented 2 months ago

Here is additional information regarding this issue and potential solutions we are considering:

A. Notifying SDK Users About Housekeeping:

When the ErrClientNotActivated error occurs, it indicates that housekeeping has taken place.

A1. If the Stream is Disconnected:

A2. If the Stream is Still Connected:

A3. If Not Maintaining a Stream (Offline Editing):

B. How Users Can Recover the Document When Receiving a Detached Event in doc.subscribe():

B1. Reactivate the Client and Reattach the Document:

B2. Implement Offline Storage Mode to Keep Unsynced Local Changes:

Initially, we plan to test using methods A1 and B1, and then move on to A2 and B2.

hackerwins commented 1 month ago

Flow for Deactivation of Outdated Clients by housekeeping:

A. Initial Setup

B. Server-side Housekeeping Processing

C. Client Re-access

D. Client-side Handling

E. Required User Actions