yorkie-team / yorkie

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

Handling reattaching detached document in SDK #904

Closed hackerwins closed 3 months ago

hackerwins commented 3 months ago

Description:

Currently, SDK provides an interface that implies the ability to reattach a detached document, as evidenced by the presence of test code within JS SDK.

However, when a specific client detaches a document, there is possibilities that tombstones of that client may be garbage collected by another peers. If an operation is generated that refers to tombstones, it could lead to a cannot find node issue.

Possible Solutions:

  1. Prevent reattaching detached documents

    • When attempting to reattach a detached document, expose an error like ErrAlreadyDetached to the user.
    • Pros: Simplifies the logic
    • Cons: Detach interface may still appear confusing as it suggests the possibility of reattachment.
  2. Allow reattaching of detached documents

    • Implement a mechanism to prevent garbage collection from occurring immediately after detachment.
    • Pros: Interface appears more intuitive
    • Cons: Potential complexity in GC functionality and error handling logic.

For now, I think it’s better to proceed with Solution 1.

Why:

hackerwins commented 3 months ago

Fixed by #908.