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

Fix missing collection of removed elements from the root #676

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

hackerwins
Copy link
Member

@hackerwins hackerwins commented Oct 27, 2023

What this PR does / why we need it?

Fix missing collection of removed elements from the root.

A document has two structures representing the user data: clone and root. When elements are removed by document.update, they are collected to removedElementMapByCreatedAt for garbage collection.

However, we found a bug in that the collection is missing in the root. So this commit fixes it.

Any background context you want to provide?

A. Luckily, the collection is not missing in Yorkie.

https://github.com/yorkie-team/yorkie/blob/a000a29d81d7e6557edfbe3cb5f2ce17b203c634/pkg/document/operations/set.go#L68-L72

B. Remove Clone from Document.

We've added clone to protect the root from unintended updates caused by document.update. However, keeping the clone and the root in sync is challenging and consumes twice as much memory. Therefore, it is better to remove the clone after introducing reverse operations from Document.history.

What are the relevant tickets?

Fixes #

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@hackerwins hackerwins changed the title Fix missing collecting of removed elements from the root Fix missing collection of removed elements from the root Oct 27, 2023
@codecov
Copy link

codecov bot commented Oct 27, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (356fd7a) 67.83% compared to head (c274c5f) 67.90%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #676      +/-   ##
==========================================
+ Coverage   67.83%   67.90%   +0.06%     
==========================================
  Files          58       58              
  Lines        8734     8737       +3     
  Branches      784      785       +1     
==========================================
+ Hits         5925     5933       +8     
+ Misses       2550     2546       -4     
+ Partials      259      258       -1     
Files Coverage Δ
src/document/document.ts 79.80% <100.00%> (+0.06%) ⬆️
src/document/operation/set_operation.ts 70.00% <100.00%> (+3.33%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hackerwins hackerwins merged commit 7c8313a into main Oct 27, 2023
2 checks passed
@hackerwins hackerwins deleted the fix-invalid-garbage-length branch October 27, 2023 03:10
@hackerwins hackerwins added the bug 🐞 Something isn't working label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant