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

Introduce Hybrid vector clock #786

Closed
wants to merge 19 commits into from
Closed

Introduce Hybrid vector clock #786

wants to merge 19 commits into from

Conversation

highcloud100
Copy link
Contributor

@highcloud100 highcloud100 commented Feb 6, 2024

What this PR does / why we need it:

Which issue(s) this PR fixes:

Address #723

Special notes for your reviewer:

https://hackmd.io/kfaV_ZAgSX-REVyKRnoU1Q?view\

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

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

1. Add synced vector map in document.
2. Add self vector clock in Change
3. Modify gc to work with min synced vector
1. Old actor id does't convert to new in syncedVectorMap
2. Change the gc criteria to RemovedAt
1. replace text edit's  latestCreatedAtMapByActor with vector clock.
2. Fix gc timing in gc_test.go, because gc changed to use vectorclock
3. Because it is used in text edit, context includes current vector.
1. Fix MinSyncedVector and add relevant test.
2. Fix duplicate vectorClock updates due to pre `context` update commit.
3. Modify gc_test.go to fit hybrid vector clock, except detach test.
1. server store synced vector map in snapshot_info.
2. The client also receives vector clock when pulling pack from the snapshot, and replace it's vector map with pulled vector map.
@hackerwins
Copy link
Member

Related to #789

1. Calculate minimum vector only when garbage is present.
2. Copy depth when inserting vector clocks into Change.
hackerwins and others added 3 commits February 10, 2024 19:33
1. Now Change has detach flag. It used to delete vectorclock of detached Actor.
1. Now snapshot save latest vector clock not SVM.
2. Clients build their own SVM using the latest VectorClock in snapshots.
- So client's SVM is not latest state, it doesn't know peer's vector clock. It need more check
- This is due to the overhead of storing and transferring SVMs. #789
Copy link

codecov bot commented Feb 12, 2024

Codecov Report

Attention: 227 lines in your changes are missing coverage. Please review.

Comparison is base (a8f6bc2) 50.71% compared to head (7df4278) 50.35%.
Report is 1 commits behind head on main.

Files Patch % Lines
server/backend/database/memory/database.go 5.88% 48 Missing ⚠️
server/backend/database/mongo/client.go 39.47% 42 Missing and 4 partials ⚠️
pkg/document/time/vector_clock.go 26.08% 33 Missing and 1 partial ⚠️
pkg/document/internal_document.go 8.57% 32 Missing ⚠️
pkg/document/change/change.go 0.00% 11 Missing ⚠️
pkg/document/change/context.go 0.00% 8 Missing ⚠️
server/backend/database/snapshot_info.go 0.00% 8 Missing ⚠️
server/rpc/admin_server.go 0.00% 7 Missing ⚠️
api/converter/from_pb.go 70.00% 4 Missing and 2 partials ⚠️
pkg/document/document.go 62.50% 5 Missing and 1 partial ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #786      +/-   ##
==========================================
- Coverage   50.71%   50.35%   -0.37%     
==========================================
  Files          70       71       +1     
  Lines       10213    10397     +184     
==========================================
+ Hits         5180     5235      +55     
- Misses       4512     4632     +120     
- Partials      521      530       +9     

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

This approach is silly.
- slow and behave like client.
- Server track all logs of clients, so we don't need calculate min synced vector every time.
Terminology
- change's vector clock -> vector clock
- change's latest vector clock -> version vector
- each document's vector clock -> version vector
- min synced vector clock -> synced version vector
- snapshot's vector clock -> latest version vector
@hackerwins
Copy link
Member

This continues at #800.

@hackerwins hackerwins closed this Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants