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

Consider elements in the undo/redo stack during garbage collection #664

Open
chacha912 opened this issue Nov 7, 2023 · 0 comments
Open
Labels
cleanup 🧹 Paying off technical debt enhancement 🌟 New feature or request hard 🧑‍🔬 Difficult to deal with or require research

Comments

@chacha912
Copy link
Contributor

chacha912 commented Nov 7, 2023

Description:

The current garbage collection behavior involves deleting elements that document replicas can no longer reference. If an element has been deleted and it occurred before minSyncedTicket, it is considered not referable by each replica. However, with the introduction of Undo/Redo, even deleted elements can still be referenced through the undo/redo stack. Consequently, they should not be garbage collected. If garbage collection occurs on elements that are still referenced in the undo/redo stack, it may lead to issues where these elements cannot be found. (Refer to the test code: Should handle the case of reverse operations referencing already garbage-collected elements) Therefore, during garbage collection, it is necessary to check elements referenced by operations in the undo/redo stack.

image
Ensure that elements referenced by operations in the undo/redo stack are not prematurely deleted during garbage collection.

Why:
The reason for this change is that even though elements may have been deleted, they can be referenced again through the undo/redo stack. As a result, an additional condition needs to be added to the garbage collection process to account for elements referenced in the undo/redo stack.

@hackerwins hackerwins added enhancement 🌟 New feature or request cleanup 🧹 Paying off technical debt labels Nov 7, 2023
@hackerwins hackerwins transferred this issue from yorkie-team/yorkie-js-sdk Nov 7, 2023
@hackerwins hackerwins added the hard 🧑‍🔬 Difficult to deal with or require research label Nov 7, 2023
hackerwins added a commit to yorkie-team/yorkie-js-sdk that referenced this issue Nov 15, 2023
1. Define reverse operations of Object.Set Object.Remove:
   1.1 Modified the set operation to compare `executedAt` with
       `getPositionedAt()` during value setting, addressing issues
       during undo.
   1.2 Set `movedAt` when the value is reassigned during undo.

2. Handle edge cases:
   When the target element is deleted by other peers
   Implemented handling to skip execution of reverse operations
   during undo and redo if the element has been deleted.

3. Add whiteboard example:
   3.1. Feature Introduction - Added a whiteboard example for testing
        undo redo operations.
   3.2. Variables Added for Displaying Yorkie Data - Added
        `CRDTRoot.opsForTest` and `CRDTElement.toJSForTest`.
   3.3. Additional Features to Apply (Todo) - Planned features include
        implementing history pause/resume, subscribing to history
        changes, and applying reverse operations for `array.add` and `array.remove`.

4. TODOs
  4.1. Set nested objects (yorkie-team/yorkie#663)
        - Modified set operation to handle nested objects.
  4.2. When the target element is garbage-collected (yorkie-team/yorkie#664)
        - Considering elements referenced by operations in the
          undo/redo stack during garbage collection.

---------

Co-authored-by: Youngteac Hong <susukang98@gmail.com>
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 hard 🧑‍🔬 Difficult to deal with or require research
Projects
Status: Todo
Development

No branches or pull requests

2 participants