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 VersionVector to detect the relationship between changes #800

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hackerwins
Copy link
Member

@hackerwins hackerwins commented Feb 22, 2024

What this PR does / why we need it:

This PR introduces VersionVector for Change.ID to differentiate between Concurrent and Causal relationships among changes.

Existing Functionality of Change.ID:

  • Allows for determining the Total Order of Changes.
  • Generates TimeTicket using a provided Delimiter.
    • Used as an ID for Elements.
    • Utilized for Conflict Resolution of Operations.
    • Only establishes order in Total Order, unable to distinguish between Concurrent and Causal relationships.

New Features of Change.ID:

  • Enables differentiation between Concurrent and Causal relationships among Changes.

We still use LamportClock in conjunction with VersionVector to reduce the size of CRDT metadata in Documents.

Which issue(s) this PR fixes:

Related to #723, #786

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Additional documentation:


Checklist:

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

Summary by CodeRabbit

  • New Features

    • Introduced version vector functionality to track the relationships between document changes.
    • Added methods for synchronizing and setting version vectors, enhancing document update tracking.
  • Bug Fixes

    • Corrected comments and improved clarity in existing methods.
  • Tests

    • Added new test cases to verify version vector handling and document updates.
  • Refactor

    • Renamed and updated functions to include version vector parameters.
    • Improved encapsulation and safety for internal types.
  • Documentation

    • Revised documentation for Ticket to clarify its purpose and limitations.

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 20.98139% with 467 lines in your changes missing coverage. Please review.

Project coverage is 46.75%. Comparing base (40f0e88) to head (42ca4e2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/document/time/version_vector.go 0.00% 114 Missing ⚠️
server/backend/database/memory/database.go 15.51% 98 Missing ⚠️
server/backend/database/mongo/client.go 22.01% 85 Missing ⚠️
pkg/document/change/id.go 13.88% 31 Missing ⚠️
server/backend/database/mongo/registry.go 40.00% 16 Missing and 8 partials ⚠️
server/packs/serverpacks.go 0.00% 23 Missing ⚠️
server/packs/packs.go 0.00% 18 Missing ⚠️
pkg/document/internal_document.go 30.00% 14 Missing ⚠️
api/converter/from_pb.go 68.42% 8 Missing and 4 partials ⚠️
api/converter/to_pb.go 62.50% 8 Missing and 4 partials ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #800      +/-   ##
==========================================
- Coverage   48.68%   46.75%   -1.93%     
==========================================
  Files          79       80       +1     
  Lines       11351    11834     +483     
==========================================
+ Hits         5526     5533       +7     
- Misses       5276     5734     +458     
- Partials      549      567      +18     
Flag Coverage Δ
46.75% <20.98%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go Benchmark

Benchmark suite Current: 30eaa9f Previous: e850ce3 Ratio
BenchmarkDocument/constructor_test 1490 ns/op 1337 B/op 24 allocs/op 1553 ns/op 1337 B/op 24 allocs/op 0.96
BenchmarkDocument/constructor_test - ns/op 1490 ns/op 1553 ns/op 0.96
BenchmarkDocument/constructor_test - B/op 1337 B/op 1337 B/op 1
BenchmarkDocument/constructor_test - allocs/op 24 allocs/op 24 allocs/op 1
BenchmarkDocument/status_test 959.3 ns/op 1305 B/op 22 allocs/op 984.6 ns/op 1305 B/op 22 allocs/op 0.97
BenchmarkDocument/status_test - ns/op 959.3 ns/op 984.6 ns/op 0.97
BenchmarkDocument/status_test - B/op 1305 B/op 1305 B/op 1
BenchmarkDocument/status_test - allocs/op 22 allocs/op 22 allocs/op 1
BenchmarkDocument/equals_test 7901 ns/op 7529 B/op 134 allocs/op 7850 ns/op 7529 B/op 134 allocs/op 1.01
BenchmarkDocument/equals_test - ns/op 7901 ns/op 7850 ns/op 1.01
BenchmarkDocument/equals_test - B/op 7529 B/op 7529 B/op 1
BenchmarkDocument/equals_test - allocs/op 134 allocs/op 134 allocs/op 1
BenchmarkDocument/nested_update_test 17103 ns/op 12395 B/op 264 allocs/op 17760 ns/op 12395 B/op 264 allocs/op 0.96
BenchmarkDocument/nested_update_test - ns/op 17103 ns/op 17760 ns/op 0.96
BenchmarkDocument/nested_update_test - B/op 12395 B/op 12395 B/op 1
BenchmarkDocument/nested_update_test - allocs/op 264 allocs/op 264 allocs/op 1
BenchmarkDocument/delete_test 23315 ns/op 15924 B/op 347 allocs/op 23502 ns/op 15924 B/op 347 allocs/op 0.99
BenchmarkDocument/delete_test - ns/op 23315 ns/op 23502 ns/op 0.99
BenchmarkDocument/delete_test - B/op 15924 B/op 15924 B/op 1
BenchmarkDocument/delete_test - allocs/op 347 allocs/op 347 allocs/op 1
BenchmarkDocument/object_test 8873 ns/op 7073 B/op 122 allocs/op 8928 ns/op 7073 B/op 122 allocs/op 0.99
BenchmarkDocument/object_test - ns/op 8873 ns/op 8928 ns/op 0.99
BenchmarkDocument/object_test - B/op 7073 B/op 7073 B/op 1
BenchmarkDocument/object_test - allocs/op 122 allocs/op 122 allocs/op 1
BenchmarkDocument/array_test 30451 ns/op 12203 B/op 278 allocs/op 29871 ns/op 12203 B/op 278 allocs/op 1.02
BenchmarkDocument/array_test - ns/op 30451 ns/op 29871 ns/op 1.02
BenchmarkDocument/array_test - B/op 12203 B/op 12203 B/op 1
BenchmarkDocument/array_test - allocs/op 278 allocs/op 278 allocs/op 1
BenchmarkDocument/text_test 36125 ns/op 15324 B/op 492 allocs/op 33929 ns/op 15260 B/op 475 allocs/op 1.06
BenchmarkDocument/text_test - ns/op 36125 ns/op 33929 ns/op 1.06
BenchmarkDocument/text_test - B/op 15324 B/op 15260 B/op 1.00
BenchmarkDocument/text_test - allocs/op 492 allocs/op 475 allocs/op 1.04
BenchmarkDocument/text_composition_test 30898 ns/op 18719 B/op 504 allocs/op 29567 ns/op 18676 B/op 486 allocs/op 1.05
BenchmarkDocument/text_composition_test - ns/op 30898 ns/op 29567 ns/op 1.05
BenchmarkDocument/text_composition_test - B/op 18719 B/op 18676 B/op 1.00
BenchmarkDocument/text_composition_test - allocs/op 504 allocs/op 486 allocs/op 1.04
BenchmarkDocument/rich_text_test 86472 ns/op 40181 B/op 1183 allocs/op 83653 ns/op 39949 B/op 1166 allocs/op 1.03
BenchmarkDocument/rich_text_test - ns/op 86472 ns/op 83653 ns/op 1.03
BenchmarkDocument/rich_text_test - B/op 40181 B/op 39949 B/op 1.01
BenchmarkDocument/rich_text_test - allocs/op 1183 allocs/op 1166 allocs/op 1.01
BenchmarkDocument/counter_test 18797 ns/op 11875 B/op 258 allocs/op 18824 ns/op 11874 B/op 258 allocs/op 1.00
BenchmarkDocument/counter_test - ns/op 18797 ns/op 18824 ns/op 1.00
BenchmarkDocument/counter_test - B/op 11875 B/op 11874 B/op 1.00
BenchmarkDocument/counter_test - allocs/op 258 allocs/op 258 allocs/op 1
BenchmarkDocument/text_edit_gc_100 1326054 ns/op 872519 B/op 17281 allocs/op 1296590 ns/op 871551 B/op 16758 allocs/op 1.02
BenchmarkDocument/text_edit_gc_100 - ns/op 1326054 ns/op 1296590 ns/op 1.02
BenchmarkDocument/text_edit_gc_100 - B/op 872519 B/op 871551 B/op 1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op 17281 allocs/op 16758 allocs/op 1.03
BenchmarkDocument/text_edit_gc_1000 50435327 ns/op 50546124 B/op 186745 allocs/op 50774056 ns/op 50535982 B/op 181729 allocs/op 0.99
BenchmarkDocument/text_edit_gc_1000 - ns/op 50435327 ns/op 50774056 ns/op 0.99
BenchmarkDocument/text_edit_gc_1000 - B/op 50546124 B/op 50535982 B/op 1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op 186745 allocs/op 181729 allocs/op 1.03
BenchmarkDocument/text_split_gc_100 1982019 ns/op 1589025 B/op 15951 allocs/op 1890819 ns/op 1529329 B/op 15610 allocs/op 1.05
BenchmarkDocument/text_split_gc_100 - ns/op 1982019 ns/op 1890819 ns/op 1.05
BenchmarkDocument/text_split_gc_100 - B/op 1589025 B/op 1529329 B/op 1.04
BenchmarkDocument/text_split_gc_100 - allocs/op 15951 allocs/op 15610 allocs/op 1.02
BenchmarkDocument/text_split_gc_1000 117321487 ns/op 141481803 B/op 186152 allocs/op 112715066 ns/op 135076866 B/op 182211 allocs/op 1.04
BenchmarkDocument/text_split_gc_1000 - ns/op 117321487 ns/op 112715066 ns/op 1.04
BenchmarkDocument/text_split_gc_1000 - B/op 141481803 B/op 135076866 B/op 1.05
BenchmarkDocument/text_split_gc_1000 - allocs/op 186152 allocs/op 182211 allocs/op 1.02
BenchmarkDocument/text_delete_all_10000 16621974 ns/op 10215162 B/op 55691 allocs/op 17390804 ns/op 10184086 B/op 40681 allocs/op 0.96
BenchmarkDocument/text_delete_all_10000 - ns/op 16621974 ns/op 17390804 ns/op 0.96
BenchmarkDocument/text_delete_all_10000 - B/op 10215162 B/op 10184086 B/op 1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op 55691 allocs/op 40681 allocs/op 1.37
BenchmarkDocument/text_delete_all_100000 281947678 ns/op 142964592 B/op 561675 allocs/op 305538717 ns/op 142676796 B/op 411702 allocs/op 0.92
BenchmarkDocument/text_delete_all_100000 - ns/op 281947678 ns/op 305538717 ns/op 0.92
BenchmarkDocument/text_delete_all_100000 - B/op 142964592 B/op 142676796 B/op 1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op 561675 allocs/op 411702 allocs/op 1.36
BenchmarkDocument/text_100 224916 ns/op 120491 B/op 5182 allocs/op 217106 ns/op 120293 B/op 5083 allocs/op 1.04
BenchmarkDocument/text_100 - ns/op 224916 ns/op 217106 ns/op 1.04
BenchmarkDocument/text_100 - B/op 120491 B/op 120293 B/op 1.00
BenchmarkDocument/text_100 - allocs/op 5182 allocs/op 5083 allocs/op 1.02
BenchmarkDocument/text_1000 2411156 ns/op 1171277 B/op 51086 allocs/op 2376651 ns/op 1169280 B/op 50087 allocs/op 1.01
BenchmarkDocument/text_1000 - ns/op 2411156 ns/op 2376651 ns/op 1.01
BenchmarkDocument/text_1000 - B/op 1171277 B/op 1169280 B/op 1.00
BenchmarkDocument/text_1000 - allocs/op 51086 allocs/op 50087 allocs/op 1.02
BenchmarkDocument/array_1000 1222597 ns/op 1091635 B/op 11833 allocs/op 1245854 ns/op 1091759 B/op 11834 allocs/op 0.98
BenchmarkDocument/array_1000 - ns/op 1222597 ns/op 1245854 ns/op 0.98
BenchmarkDocument/array_1000 - B/op 1091635 B/op 1091759 B/op 1.00
BenchmarkDocument/array_1000 - allocs/op 11833 allocs/op 11834 allocs/op 1.00
BenchmarkDocument/array_10000 13295919 ns/op 9799980 B/op 120297 allocs/op 13295303 ns/op 9800211 B/op 120299 allocs/op 1.00
BenchmarkDocument/array_10000 - ns/op 13295919 ns/op 13295303 ns/op 1.00
BenchmarkDocument/array_10000 - B/op 9799980 B/op 9800211 B/op 1.00
BenchmarkDocument/array_10000 - allocs/op 120297 allocs/op 120299 allocs/op 1.00
BenchmarkDocument/array_gc_100 148262 ns/op 133262 B/op 1266 allocs/op 151646 ns/op 133276 B/op 1266 allocs/op 0.98
BenchmarkDocument/array_gc_100 - ns/op 148262 ns/op 151646 ns/op 0.98
BenchmarkDocument/array_gc_100 - B/op 133262 B/op 133276 B/op 1.00
BenchmarkDocument/array_gc_100 - allocs/op 1266 allocs/op 1266 allocs/op 1
BenchmarkDocument/array_gc_1000 1435494 ns/op 1159696 B/op 12882 allocs/op 1434116 ns/op 1159646 B/op 12882 allocs/op 1.00
BenchmarkDocument/array_gc_1000 - ns/op 1435494 ns/op 1434116 ns/op 1.00
BenchmarkDocument/array_gc_1000 - B/op 1159696 B/op 1159646 B/op 1.00
BenchmarkDocument/array_gc_1000 - allocs/op 12882 allocs/op 12882 allocs/op 1
BenchmarkDocument/counter_1000 203302 ns/op 193337 B/op 5773 allocs/op 202950 ns/op 193337 B/op 5773 allocs/op 1.00
BenchmarkDocument/counter_1000 - ns/op 203302 ns/op 202950 ns/op 1.00
BenchmarkDocument/counter_1000 - B/op 193337 B/op 193337 B/op 1
BenchmarkDocument/counter_1000 - allocs/op 5773 allocs/op 5773 allocs/op 1
BenchmarkDocument/counter_10000 2183935 ns/op 2088252 B/op 59780 allocs/op 2180696 ns/op 2088252 B/op 59780 allocs/op 1.00
BenchmarkDocument/counter_10000 - ns/op 2183935 ns/op 2180696 ns/op 1.00
BenchmarkDocument/counter_10000 - B/op 2088252 B/op 2088252 B/op 1
BenchmarkDocument/counter_10000 - allocs/op 59780 allocs/op 59780 allocs/op 1
BenchmarkDocument/object_1000 1388791 ns/op 1428106 B/op 9850 allocs/op 1440343 ns/op 1428580 B/op 9851 allocs/op 0.96
BenchmarkDocument/object_1000 - ns/op 1388791 ns/op 1440343 ns/op 0.96
BenchmarkDocument/object_1000 - B/op 1428106 B/op 1428580 B/op 1.00
BenchmarkDocument/object_1000 - allocs/op 9850 allocs/op 9851 allocs/op 1.00
BenchmarkDocument/object_10000 15138933 ns/op 12168236 B/op 100569 allocs/op 15772885 ns/op 12167137 B/op 100566 allocs/op 0.96
BenchmarkDocument/object_10000 - ns/op 15138933 ns/op 15772885 ns/op 0.96
BenchmarkDocument/object_10000 - B/op 12168236 B/op 12167137 B/op 1.00
BenchmarkDocument/object_10000 - allocs/op 100569 allocs/op 100566 allocs/op 1.00
BenchmarkDocument/tree_100 1032786 ns/op 943956 B/op 6103 allocs/op 1083691 ns/op 943960 B/op 6103 allocs/op 0.95
BenchmarkDocument/tree_100 - ns/op 1032786 ns/op 1083691 ns/op 0.95
BenchmarkDocument/tree_100 - B/op 943956 B/op 943960 B/op 1.00
BenchmarkDocument/tree_100 - allocs/op 6103 allocs/op 6103 allocs/op 1
BenchmarkDocument/tree_1000 72775562 ns/op 86460037 B/op 60117 allocs/op 79621224 ns/op 86460101 B/op 60116 allocs/op 0.91
BenchmarkDocument/tree_1000 - ns/op 72775562 ns/op 79621224 ns/op 0.91
BenchmarkDocument/tree_1000 - B/op 86460037 B/op 86460101 B/op 1.00
BenchmarkDocument/tree_1000 - allocs/op 60117 allocs/op 60116 allocs/op 1.00
BenchmarkDocument/tree_10000 9411952109 ns/op 8580661328 B/op 600221 allocs/op 9795036956 ns/op 8580667568 B/op 600210 allocs/op 0.96
BenchmarkDocument/tree_10000 - ns/op 9411952109 ns/op 9795036956 ns/op 0.96
BenchmarkDocument/tree_10000 - B/op 8580661328 B/op 8580667568 B/op 1.00
BenchmarkDocument/tree_10000 - allocs/op 600221 allocs/op 600210 allocs/op 1.00
BenchmarkDocument/tree_delete_all_1000 74794724 ns/op 87508477 B/op 75267 allocs/op 78694522 ns/op 87510043 B/op 75270 allocs/op 0.95
BenchmarkDocument/tree_delete_all_1000 - ns/op 74794724 ns/op 78694522 ns/op 0.95
BenchmarkDocument/tree_delete_all_1000 - B/op 87508477 B/op 87510043 B/op 1.00
BenchmarkDocument/tree_delete_all_1000 - allocs/op 75267 allocs/op 75270 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_100 3848348 ns/op 4147258 B/op 15147 allocs/op 3840381 ns/op 4147221 B/op 15146 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_100 - ns/op 3848348 ns/op 3840381 ns/op 1.00
BenchmarkDocument/tree_edit_gc_100 - B/op 4147258 B/op 4147221 B/op 1.00
BenchmarkDocument/tree_edit_gc_100 - allocs/op 15147 allocs/op 15146 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_1000 300390870 ns/op 383744998 B/op 154866 allocs/op 311566922 ns/op 383747742 B/op 154868 allocs/op 0.96
BenchmarkDocument/tree_edit_gc_1000 - ns/op 300390870 ns/op 311566922 ns/op 0.96
BenchmarkDocument/tree_edit_gc_1000 - B/op 383744998 B/op 383747742 B/op 1.00
BenchmarkDocument/tree_edit_gc_1000 - allocs/op 154866 allocs/op 154868 allocs/op 1.00
BenchmarkDocument/tree_split_gc_100 2521830 ns/op 2413086 B/op 11131 allocs/op 2573562 ns/op 2413807 B/op 11131 allocs/op 0.98
BenchmarkDocument/tree_split_gc_100 - ns/op 2521830 ns/op 2573562 ns/op 0.98
BenchmarkDocument/tree_split_gc_100 - B/op 2413086 B/op 2413807 B/op 1.00
BenchmarkDocument/tree_split_gc_100 - allocs/op 11131 allocs/op 11131 allocs/op 1
BenchmarkDocument/tree_split_gc_1000 179664420 ns/op 222253841 B/op 121996 allocs/op 185155432 ns/op 222251437 B/op 122003 allocs/op 0.97
BenchmarkDocument/tree_split_gc_1000 - ns/op 179664420 ns/op 185155432 ns/op 0.97
BenchmarkDocument/tree_split_gc_1000 - B/op 222253841 B/op 222251437 B/op 1.00
BenchmarkDocument/tree_split_gc_1000 - allocs/op 121996 allocs/op 122003 allocs/op 1.00
BenchmarkRPC/client_to_server 421721731 ns/op 20019514 B/op 208636 allocs/op 424746172 ns/op 19207266 B/op 208638 allocs/op 0.99
BenchmarkRPC/client_to_server - ns/op 421721731 ns/op 424746172 ns/op 0.99
BenchmarkRPC/client_to_server - B/op 20019514 B/op 19207266 B/op 1.04
BenchmarkRPC/client_to_server - allocs/op 208636 allocs/op 208638 allocs/op 1.00
BenchmarkRPC/client_to_client_via_server 795099518 ns/op 38816908 B/op 430563 allocs/op 804526225 ns/op 38901196 B/op 430946 allocs/op 0.99
BenchmarkRPC/client_to_client_via_server - ns/op 795099518 ns/op 804526225 ns/op 0.99
BenchmarkRPC/client_to_client_via_server - B/op 38816908 B/op 38901196 B/op 1.00
BenchmarkRPC/client_to_client_via_server - allocs/op 430563 allocs/op 430946 allocs/op 1.00
BenchmarkRPC/attach_large_document 1189541711 ns/op 1885069112 B/op 9842 allocs/op 1143860472 ns/op 1919923464 B/op 9879 allocs/op 1.04
BenchmarkRPC/attach_large_document - ns/op 1189541711 ns/op 1143860472 ns/op 1.04
BenchmarkRPC/attach_large_document - B/op 1885069112 B/op 1919923464 B/op 0.98
BenchmarkRPC/attach_large_document - allocs/op 9842 allocs/op 9879 allocs/op 1.00
BenchmarkRPC/adminCli_to_server 538927051 ns/op 35957688 B/op 289539 allocs/op 543157706 ns/op 36775384 B/op 289584 allocs/op 0.99
BenchmarkRPC/adminCli_to_server - ns/op 538927051 ns/op 543157706 ns/op 0.99
BenchmarkRPC/adminCli_to_server - B/op 35957688 B/op 36775384 B/op 0.98
BenchmarkRPC/adminCli_to_server - allocs/op 289539 allocs/op 289584 allocs/op 1.00
BenchmarkLocker 64.39 ns/op 16 B/op 1 allocs/op 65.44 ns/op 16 B/op 1 allocs/op 0.98
BenchmarkLocker - ns/op 64.39 ns/op 65.44 ns/op 0.98
BenchmarkLocker - B/op 16 B/op 16 B/op 1
BenchmarkLocker - allocs/op 1 allocs/op 1 allocs/op 1
BenchmarkLockerParallel 39.99 ns/op 0 B/op 0 allocs/op 40.02 ns/op 0 B/op 0 allocs/op 1.00
BenchmarkLockerParallel - ns/op 39.99 ns/op 40.02 ns/op 1.00
BenchmarkLockerParallel - B/op 0 B/op 0 B/op 1
BenchmarkLockerParallel - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkLockerMoreKeys 148.5 ns/op 15 B/op 0 allocs/op 147.8 ns/op 15 B/op 0 allocs/op 1.00
BenchmarkLockerMoreKeys - ns/op 148.5 ns/op 147.8 ns/op 1.00
BenchmarkLockerMoreKeys - B/op 15 B/op 15 B/op 1
BenchmarkLockerMoreKeys - allocs/op 0 allocs/op 0 allocs/op 1
BenchmarkChange/Push_10_Changes 4477113 ns/op 143270 B/op 1572 allocs/op 4452754 ns/op 142997 B/op 1565 allocs/op 1.01
BenchmarkChange/Push_10_Changes - ns/op 4477113 ns/op 4452754 ns/op 1.01
BenchmarkChange/Push_10_Changes - B/op 143270 B/op 142997 B/op 1.00
BenchmarkChange/Push_10_Changes - allocs/op 1572 allocs/op 1565 allocs/op 1.00
BenchmarkChange/Push_100_Changes 16617858 ns/op 697529 B/op 8188 allocs/op 16188409 ns/op 697188 B/op 8182 allocs/op 1.03
BenchmarkChange/Push_100_Changes - ns/op 16617858 ns/op 16188409 ns/op 1.03
BenchmarkChange/Push_100_Changes - B/op 697529 B/op 697188 B/op 1.00
BenchmarkChange/Push_100_Changes - allocs/op 8188 allocs/op 8182 allocs/op 1.00
BenchmarkChange/Push_1000_Changes 133104970 ns/op 6529068 B/op 77154 allocs/op 128268887 ns/op 6748467 B/op 77156 allocs/op 1.04
BenchmarkChange/Push_1000_Changes - ns/op 133104970 ns/op 128268887 ns/op 1.04
BenchmarkChange/Push_1000_Changes - B/op 6529068 B/op 6748467 B/op 0.97
BenchmarkChange/Push_1000_Changes - allocs/op 77154 allocs/op 77156 allocs/op 1.00
BenchmarkChange/Pull_10_Changes 3698522 ns/op 123688 B/op 1405 allocs/op 3718192 ns/op 123661 B/op 1405 allocs/op 0.99
BenchmarkChange/Pull_10_Changes - ns/op 3698522 ns/op 3718192 ns/op 0.99
BenchmarkChange/Pull_10_Changes - B/op 123688 B/op 123661 B/op 1.00
BenchmarkChange/Pull_10_Changes - allocs/op 1405 allocs/op 1405 allocs/op 1
BenchmarkChange/Pull_100_Changes 5237278 ns/op 350522 B/op 4949 allocs/op 5319390 ns/op 350461 B/op 4949 allocs/op 0.98
BenchmarkChange/Pull_100_Changes - ns/op 5237278 ns/op 5319390 ns/op 0.98
BenchmarkChange/Pull_100_Changes - B/op 350522 B/op 350461 B/op 1.00
BenchmarkChange/Pull_100_Changes - allocs/op 4949 allocs/op 4949 allocs/op 1
BenchmarkChange/Pull_1000_Changes 10182820 ns/op 2220521 B/op 42668 allocs/op 10467731 ns/op 2214043 B/op 42667 allocs/op 0.97
BenchmarkChange/Pull_1000_Changes - ns/op 10182820 ns/op 10467731 ns/op 0.97
BenchmarkChange/Pull_1000_Changes - B/op 2220521 B/op 2214043 B/op 1.00
BenchmarkChange/Pull_1000_Changes - allocs/op 42668 allocs/op 42667 allocs/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot 19226389 ns/op 813796 B/op 8189 allocs/op 18296194 ns/op 814987 B/op 8190 allocs/op 1.05
BenchmarkSnapshot/Push_3KB_snapshot - ns/op 19226389 ns/op 18296194 ns/op 1.05
BenchmarkSnapshot/Push_3KB_snapshot - B/op 813796 B/op 814987 B/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op 8189 allocs/op 8190 allocs/op 1.00
BenchmarkSnapshot/Push_30KB_snapshot 134352897 ns/op 7172413 B/op 77770 allocs/op 130492825 ns/op 7433710 B/op 78757 allocs/op 1.03
BenchmarkSnapshot/Push_30KB_snapshot - ns/op 134352897 ns/op 130492825 ns/op 1.03
BenchmarkSnapshot/Push_30KB_snapshot - B/op 7172413 B/op 7433710 B/op 0.96
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op 77770 allocs/op 78757 allocs/op 0.99
BenchmarkSnapshot/Pull_3KB_snapshot 7253425 ns/op 1136638 B/op 19415 allocs/op 7367906 ns/op 1136637 B/op 19415 allocs/op 0.98
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op 7253425 ns/op 7367906 ns/op 0.98
BenchmarkSnapshot/Pull_3KB_snapshot - B/op 1136638 B/op 1136637 B/op 1.00
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op 19415 allocs/op 19415 allocs/op 1
BenchmarkSnapshot/Pull_30KB_snapshot 17433543 ns/op 9292430 B/op 187557 allocs/op 17935755 ns/op 9287157 B/op 187555 allocs/op 0.97
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op 17433543 ns/op 17935755 ns/op 0.97
BenchmarkSnapshot/Pull_30KB_snapshot - B/op 9292430 B/op 9287157 B/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op 187557 allocs/op 187555 allocs/op 1.00
BenchmarkSplayTree/stress_test_100000 0.1887 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/stress_test_100000 - ns/op 0.1887 ns/op
BenchmarkSplayTree/stress_test_100000 - B/op 0 B/op
BenchmarkSplayTree/stress_test_100000 - allocs/op 0 allocs/op
BenchmarkSplayTree/stress_test_200000 0.3691 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/stress_test_200000 - ns/op 0.3691 ns/op
BenchmarkSplayTree/stress_test_200000 - B/op 0 B/op
BenchmarkSplayTree/stress_test_200000 - allocs/op 0 allocs/op
BenchmarkSplayTree/stress_test_300000 0.5687 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/stress_test_300000 - ns/op 0.5687 ns/op
BenchmarkSplayTree/stress_test_300000 - B/op 0 B/op
BenchmarkSplayTree/stress_test_300000 - allocs/op 0 allocs/op
BenchmarkSplayTree/random_access_100000 0.01245 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/random_access_100000 - ns/op 0.01245 ns/op
BenchmarkSplayTree/random_access_100000 - B/op 0 B/op
BenchmarkSplayTree/random_access_100000 - allocs/op 0 allocs/op
BenchmarkSplayTree/random_access_200000 0.02356 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/random_access_200000 - ns/op 0.02356 ns/op
BenchmarkSplayTree/random_access_200000 - B/op 0 B/op
BenchmarkSplayTree/random_access_200000 - allocs/op 0 allocs/op
BenchmarkSplayTree/random_access_300000 0.03537 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/random_access_300000 - ns/op 0.03537 ns/op
BenchmarkSplayTree/random_access_300000 - B/op 0 B/op
BenchmarkSplayTree/random_access_300000 - allocs/op 0 allocs/op
BenchmarkSplayTree/editing_trace_bench 0.001712 ns/op 0 B/op 0 allocs/op
BenchmarkSplayTree/editing_trace_bench - ns/op 0.001712 ns/op
BenchmarkSplayTree/editing_trace_bench - B/op 0 B/op
BenchmarkSplayTree/editing_trace_bench - allocs/op 0 allocs/op
BenchmarkSync/memory_sync_10_test 7046 ns/op 1287 B/op 38 allocs/op 7356 ns/op 1287 B/op 38 allocs/op 0.96
BenchmarkSync/memory_sync_10_test - ns/op 7046 ns/op 7356 ns/op 0.96
BenchmarkSync/memory_sync_10_test - B/op 1287 B/op 1287 B/op 1
BenchmarkSync/memory_sync_10_test - allocs/op 38 allocs/op 38 allocs/op 1
BenchmarkSync/memory_sync_100_test 51244 ns/op 8643 B/op 273 allocs/op 53050 ns/op 8622 B/op 272 allocs/op 0.97
BenchmarkSync/memory_sync_100_test - ns/op 51244 ns/op 53050 ns/op 0.97
BenchmarkSync/memory_sync_100_test - B/op 8643 B/op 8622 B/op 1.00
BenchmarkSync/memory_sync_100_test - allocs/op 273 allocs/op 272 allocs/op 1.00
BenchmarkSync/memory_sync_1000_test 587788 ns/op 74348 B/op 2121 allocs/op 594864 ns/op 73926 B/op 2094 allocs/op 0.99
BenchmarkSync/memory_sync_1000_test - ns/op 587788 ns/op 594864 ns/op 0.99
BenchmarkSync/memory_sync_1000_test - B/op 74348 B/op 73926 B/op 1.01
BenchmarkSync/memory_sync_1000_test - allocs/op 2121 allocs/op 2094 allocs/op 1.01
BenchmarkSync/memory_sync_10000_test 7298375 ns/op 735317 B/op 20283 allocs/op 7519496 ns/op 738128 B/op 20273 allocs/op 0.97
BenchmarkSync/memory_sync_10000_test - ns/op 7298375 ns/op 7519496 ns/op 0.97
BenchmarkSync/memory_sync_10000_test - B/op 735317 B/op 738128 B/op 1.00
BenchmarkSync/memory_sync_10000_test - allocs/op 20283 allocs/op 20273 allocs/op 1.00
BenchmarkTextEditing 5164269013 ns/op 3982584800 B/op 20647656 allocs/op 5217425050 ns/op 3980875552 B/op 19782259 allocs/op 0.99
BenchmarkTextEditing - ns/op 5164269013 ns/op 5217425050 ns/op 0.99
BenchmarkTextEditing - B/op 3982584800 B/op 3980875552 B/op 1.00
BenchmarkTextEditing - allocs/op 20647656 allocs/op 19782259 allocs/op 1.04
BenchmarkTree/10000_vertices_to_protobuf 3418758 ns/op 6262969 B/op 70025 allocs/op 3540018 ns/op 6262993 B/op 70025 allocs/op 0.97
BenchmarkTree/10000_vertices_to_protobuf - ns/op 3418758 ns/op 3540018 ns/op 0.97
BenchmarkTree/10000_vertices_to_protobuf - B/op 6262969 B/op 6262993 B/op 1.00
BenchmarkTree/10000_vertices_to_protobuf - allocs/op 70025 allocs/op 70025 allocs/op 1
BenchmarkTree/10000_vertices_from_protobuf 148661321 ns/op 442171610 B/op 290052 allocs/op 160913921 ns/op 442171388 B/op 290038 allocs/op 0.92
BenchmarkTree/10000_vertices_from_protobuf - ns/op 148661321 ns/op 160913921 ns/op 0.92
BenchmarkTree/10000_vertices_from_protobuf - B/op 442171610 B/op 442171388 B/op 1.00
BenchmarkTree/10000_vertices_from_protobuf - allocs/op 290052 allocs/op 290038 allocs/op 1.00
BenchmarkTree/20000_vertices_to_protobuf 7471257 ns/op 12716971 B/op 140028 allocs/op 7752583 ns/op 12716926 B/op 140028 allocs/op 0.96
BenchmarkTree/20000_vertices_to_protobuf - ns/op 7471257 ns/op 7752583 ns/op 0.96
BenchmarkTree/20000_vertices_to_protobuf - B/op 12716971 B/op 12716926 B/op 1.00
BenchmarkTree/20000_vertices_to_protobuf - allocs/op 140028 allocs/op 140028 allocs/op 1
BenchmarkTree/20000_vertices_from_protobuf 676621328 ns/op 1697276880 B/op 580091 allocs/op 707566139 ns/op 1697268088 B/op 580044 allocs/op 0.96
BenchmarkTree/20000_vertices_from_protobuf - ns/op 676621328 ns/op 707566139 ns/op 0.96
BenchmarkTree/20000_vertices_from_protobuf - B/op 1697276880 B/op 1697268088 B/op 1.00
BenchmarkTree/20000_vertices_from_protobuf - allocs/op 580091 allocs/op 580044 allocs/op 1.00
BenchmarkTree/30000_vertices_to_protobuf 12242113 ns/op 19318242 B/op 210030 allocs/op 12662832 ns/op 19318322 B/op 210030 allocs/op 0.97
BenchmarkTree/30000_vertices_to_protobuf - ns/op 12242113 ns/op 12662832 ns/op 0.97
BenchmarkTree/30000_vertices_to_protobuf - B/op 19318242 B/op 19318322 B/op 1.00
BenchmarkTree/30000_vertices_to_protobuf - allocs/op 210030 allocs/op 210030 allocs/op 1
BenchmarkTree/30000_vertices_from_protobuf 1615809199 ns/op 3752052408 B/op 870049 allocs/op 1629436613 ns/op 3752044648 B/op 870053 allocs/op 0.99
BenchmarkTree/30000_vertices_from_protobuf - ns/op 1615809199 ns/op 1629436613 ns/op 0.99
BenchmarkTree/30000_vertices_from_protobuf - B/op 3752052408 B/op 3752044648 B/op 1.00
BenchmarkTree/30000_vertices_from_protobuf - allocs/op 870049 allocs/op 870053 allocs/op 1.00

This comment was automatically generated by workflow using github-action-benchmark.

hackerwins added a commit that referenced this pull request May 8, 2024
We will use maxCreatedAtMapByActor until the introduction of
VersionVector. #800
Copy link

coderabbitai bot commented Jul 15, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a version vector mechanism to track relationships between document changes, enhancing conflict resolution and synchronization. New fields and methods across various components support this functionality, including updates to the ID struct, document handling, database interactions, and test cases to ensure proper version vector management.

Changes

File(s) Change Summary
pkg/document/change/id.go Added versionVector field to ID struct, updated methods for version vector management, and introduced causal relationship handling.
pkg/document/change/pack.go, pkg/document/document.go, pkg/document/internal_document.go Updated to integrate version vector handling in documents and change packs, including new methods and parameters.
pkg/document/document_test.go Added tests for version vector functionality and updated existing tests.
pkg/document/time/actor_id.go Refactored ActorID to use a new internal type for better abstraction.
pkg/document/time/ticket.go Revised documentation for Ticket struct.
pkg/document/time/version_vector.go Introduced VersionVector type and methods for managing version vectors.
server/backend/database/change_info.go, server/backend/database/database.go, server/backend/database/memory/database.go, server/backend/database/mongo/client.go, server/backend/database/mongo/registry.go, server/backend/database/mongo/registry_test.go, server/backend/database/snapshot_info.go Added VersionVector fields and updated methods for version vector handling in database interactions and registry.
server/packs/packs.go, server/packs/pushpull.go, server/packs/serverpacks.go, server/packs/snapshots.go Enhanced PushPull and snapshot storage methods to integrate version vectors, updated server packs with new fields.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Database

    Client->>Server: Send Change Pack
    Server->>Database: Store Change with VersionVector
    Database-->>Server: Acknowledge Storage
    Server-->>Client: Confirm Change Applied

    Note over Server: Pull Snapshot
    Client->>Server: Request Snapshot
    Server->>Database: Fetch Snapshot with VersionVector
    Database-->>Server: Return Snapshot
    Server-->>Client: Deliver Snapshot with VersionVector
Loading

Poem

In the world of docs we dwell,
Version vectors now to tell,
Changes sync with graceful flow,
Causal paths we clearly show.
Actors dance, their clocks align,
Harmony in code divine.
🐇✨📜


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hackerwins
Copy link
Member Author

@coderabbitai resume

Copy link

coderabbitai bot commented Jul 15, 2024

Actions performed

Reviews resumed.

Copy link

coderabbitai bot commented Jul 15, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hackerwins hackerwins marked this pull request as ready for review July 15, 2024 09:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (3)
api/yorkie/v1/resources.proto (1)

46-49: Issue Found: New fields in ChangePack are not being utilized.

The new fields snapshot_version_vector and min_synced_version_vector in the ChangePack message are defined but not used in the codebase. Ensure these fields are properly integrated and handled in the logic where ChangePack is utilized.

  • api/yorkie/v1/resources.proto
  • api/yorkie/v1/resources.pb.go
  • api/docs/yorkie/v1/resources.openapi.yaml
  • api/docs/yorkie/v1/yorkie.openapi.yaml
Analysis chain

LGTM! Verify the handling of the new fields.

The ChangePack message has new fields: VersionVector snapshot_version_vector and VersionVector min_synced_version_vector. Ensure that these fields are handled correctly in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `ChangePack` handle the new fields correctly.

# Test: Search for the message usage. Expect: Proper handling of the new fields.
rg --type proto -A 5 $'ChangePack'

Length of output: 63


Script:

#!/bin/bash
# Description: Verify all usages of `ChangePack` handle the new fields correctly.

# Test: Search for the message usage. Expect: Proper handling of the new fields.
rg -A 5 'ChangePack'

Length of output: 69068


Script:

#!/bin/bash
# Description: Verify the correct handling of new fields in ChangePack.

# Test: Search for the new fields in ChangePack. Expect: Proper handling of the new fields.
rg -A 5 'snapshot_version_vector|min_synced_version_vector'

Length of output: 4285


Script:

#!/bin/bash
# Description: Verify the correct handling of new fields in ChangePack.

# Test: Search for the usage of the new fields in ChangePack. Expect: Proper handling of the new fields.
rg 'snapshot_version_vector|min_synced_version_vector'

Length of output: 1189

server/backend/database/mongo/client.go (1)

Line range hint 1104-1146:
LGTM! Updated UpdateAndFindMinSyncedTime to return VersionVector.

The update to return a VersionVector aligns with the PR's objective to handle version vectors. The TODO comment indicates that the implementation for building the version vector is pending.

Do you need assistance with implementing the version vector building logic?

api/docs/yorkie/v1/resources.openapi.yaml (1)

3-3: Update the description for clarity.

The description is clear and provides a good overview of Yorkie. However, consider adding more details about the new VersionVector feature to provide better context.

-  description: Yorkie is an open source document store for building collaborative
+  description: Yorkie is an open-source document store for building collaborative editing applications. The latest version introduces the `VersionVector` feature for better tracking and synchronization of document changes.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b468f8b and c815a09.

Files ignored due to path filters (2)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
  • api/yorkie/v1/resources.pb.go is excluded by !**/*.pb.go
Files selected for processing (32)
  • admin/client.go (1 hunks)
  • api/converter/from_pb.go (2 hunks)
  • api/converter/to_pb.go (2 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (53 hunks)
  • api/docs/yorkie/v1/resources.openapi.yaml (63 hunks)
  • api/docs/yorkie/v1/yorkie.openapi.yaml (49 hunks)
  • api/yorkie/v1/admin.proto (1 hunks)
  • api/yorkie/v1/resources.proto (2 hunks)
  • pkg/document/change/change.go (1 hunks)
  • pkg/document/change/id.go (5 hunks)
  • pkg/document/change/pack.go (2 hunks)
  • pkg/document/crdt/root_test.go (1 hunks)
  • pkg/document/document.go (2 hunks)
  • pkg/document/document_test.go (3 hunks)
  • pkg/document/internal_document.go (8 hunks)
  • pkg/document/time/actor_id.go (1 hunks)
  • pkg/document/time/ticket.go (1 hunks)
  • pkg/document/time/vection_vector.go (1 hunks)
  • server/backend/database/change_info.go (2 hunks)
  • server/backend/database/database.go (1 hunks)
  • server/backend/database/memory/database.go (7 hunks)
  • server/backend/database/mongo/client.go (5 hunks)
  • server/backend/database/mongo/registry.go (3 hunks)
  • server/backend/database/mongo/registry_test.go (1 hunks)
  • server/backend/database/snapshot_info.go (3 hunks)
  • server/packs/packs.go (3 hunks)
  • server/packs/pushpull.go (1 hunks)
  • server/packs/serverpacks.go (3 hunks)
  • server/packs/snapshots.go (1 hunks)
  • server/rpc/admin_server.go (1 hunks)
  • server/rpc/testcases/testcases.go (4 hunks)
  • test/integration/gc_test.go (1 hunks)
Files not summarized due to errors (1)
  • api/docs/yorkie/v1/admin.openapi.yaml: Error: Message exceeds token limit
Files skipped from review due to trivial changes (2)
  • api/docs/yorkie/v1/yorkie.openapi.yaml
  • pkg/document/time/ticket.go
Additional comments not posted (88)
server/backend/database/snapshot_info.go (3)

20-23: LGTM! Import alias change and new import.

The alias change avoids naming conflicts and the new import is necessary for handling version vectors.


43-44: LGTM! Added VersionVector field to SnapshotInfo struct.

The new field is necessary for tracking version vectors in snapshots.


60-67: LGTM! Updated DeepCopy method to include VersionVector.

The update ensures that the VersionVector field is copied when creating a deep copy of SnapshotInfo.

pkg/document/change/pack.go (2)

38-44: LGTM! Added SnapshotVersionVector and MinSyncedVersionVector fields to Pack struct.

The new fields are necessary for handling version vectors in change packs.


68-68: LGTM! Updated NewPack function to initialize new fields.

The update ensures that the new fields are properly initialized when creating a new Pack.

pkg/document/time/vection_vector.go (4)

27-29: LGTM! Introduced new VersionVector type.

The new type is necessary for managing version vectors.


31-34: LGTM! Introduced NewVersionVector function.

The new function is necessary for creating instances of VersionVector.


36-44: LGTM! Introduced Set and VersionOf methods.

The new methods are necessary for managing versions within a VersionVector.


46-98: LGTM! Introduced DeepCopy, Marshal, and CausallyAfter methods.

The new methods are necessary for deep copying, serializing, and comparing VersionVector instances.

server/packs/snapshots.go (1)

80-80: LGTM! Updated storeSnapshot function to include VersionVector parameter.

The update ensures that the version vector is properly handled when storing snapshots.

server/backend/database/mongo/registry_test.go (2)

38-47: LGTM!

The test case for types.ID correctly verifies the marshaling and unmarshaling process.


50-65: LGTM!

The test case for versionVector correctly verifies the marshaling and unmarshaling process.

pkg/document/change/change.go (1)

116-119: LGTM!

The CausallyAfter method correctly checks if the current change is causally after another change.

server/backend/database/change_info.go (2)

43-50: LGTM!

The VersionVector field is correctly added to the ChangeInfo struct.


97-97: LGTM!

The ToChange method correctly initializes the changeID with the VersionVector field.

api/yorkie/v1/admin.proto (1)

143-143: LGTM!

The VersionVector field is correctly added to the GetSnapshotMetaResponse message.

pkg/document/time/actor_id.go (1)

59-60: Good abstraction of internal type.

Changing the internal type of ActorID to bytes actorID improves encapsulation and reduces the risk of errors.

server/backend/database/mongo/registry.go (5)

27-31: Necessary imports added.

The new imports for proto, converter, and api/yorkie/v1 are necessary for handling the VersionVector type.


37-37: Added type for VersionVector.

The new type tVersionVector is required for encoding and decoding the VersionVector.


52-52: Registered VersionVector decoder.

The registration of the VersionVector decoder is necessary for decoding the VersionVector from BSON.


57-57: Registered VersionVector encoder.

The registration of the VersionVector encoder is necessary for encoding the VersionVector to BSON.


87-135: Added functions for VersionVector encoding and decoding.

The versionVectorEncoder and versionVectorDecoder functions are crucial for converting VersionVector to and from BSON format.

server/packs/serverpacks.go (2)

46-50: Added fields for version vectors.

The new fields SnapshotVersionVector and MinSyncedVersionVector in the ServerPack struct are necessary for handling version vectors.


Line range hint 102-150:
Updated ToPBChangePack method.

The ToPBChangePack method has been updated to handle SnapshotVersionVector, which is necessary for converting the ServerPack to the Protobuf format.

pkg/document/change/id.go (5)

31-31: Initialized InitialID with VersionVector.

The InitialID now includes the InitialVersionVector, ensuring proper tracking from the initial state.


54-58: Added versionVector field to ID struct.

The versionVector field in the ID struct is necessary for detecting the relationship between changes.


67-74: Updated NewID function.

The NewID function now includes the versionVector parameter, which is necessary for creating an ID with the version vector.


80-87: Updated Next method.

The Next method now includes the versionVector, ensuring that the next ID includes the updated version vector.


Line range hint 100-168:
Updated methods to handle versionVector.

The SyncClocks, SetClocks, SetActor, and SetServerSeq methods, and the VersionVector and CausallyAfter methods have been updated to handle the versionVector, ensuring proper synchronization and comparison of ID instances.

server/packs/pushpull.go (1)

174-177: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to pullSnapshot correctly handle the new VersionVector logic.

server/packs/packs.go (2)

Line range hint 133-142:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to PushPull correctly handle the new minSyncedVersionVector logic.


236-236: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to BuildDocumentForServerSeq correctly handle the new VersionVector logic.

admin/client.go (2)

339-339: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to NewInternalDocumentFromSnapshot correctly handle the new VersionVector logic.

Verification successful

Let's gather more context around the calls to NewInternalDocumentFromSnapshot to ensure that the VersionVector logic is correctly handled.


Function usage verified

The function NewInternalDocumentFromSnapshot is correctly handling the new VersionVector logic in all identified instances.

  • server/packs/snapshots.go
  • server/packs/packs.go
  • admin/client.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `NewInternalDocumentFromSnapshot` handle the new `VersionVector` logic.

# Test: Search for the function usage. Expect: Correct handling of `VersionVector`.
rg --type go -A 5 $'NewInternalDocumentFromSnapshot'

Length of output: 1398


Script:

#!/bin/bash
# Description: Gather more context around the calls to `NewInternalDocumentFromSnapshot` to verify correct handling of `VersionVector`.

# Fetching additional lines around the function calls to understand the context.
rg --type go -A 10 -B 10 $'NewInternalDocumentFromSnapshot'

Length of output: 3831


330-334: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to ListChangeSummaries correctly handle the new VersionVector logic.

server/backend/database/database.go (1)

249-256: LGTM! Verify the handling of the new return type.

The function signature has been updated to return *time.VersionVector. Ensure that all calls to this function handle the new return type correctly.

Verification successful

The new return type is handled correctly.

The function UpdateAndFindMinSyncedTime returns *time.VersionVector, which is correctly assigned to minSyncedVersionVector and subsequently used in respPack.MinSyncedVersionVector.

  • server/packs/packs.go: minSyncedVersionVector is correctly assigned and used.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all calls to `UpdateAndFindMinSyncedTime` handle the new return type correctly.

# Test: Search for the function usage. Expect: Proper handling of the new return type.
rg --type go -A 5 $'UpdateAndFindMinSyncedTime'

Length of output: 2195


Script:

#!/bin/bash
# Description: Verify the handling of the new return type `*time.VersionVector` in `server/packs/packs.go`.

# Test: Search for the usage of `minSyncedVersionVector` in `server/packs/packs.go`.
rg --type go -A 10 'minSyncedVersionVector' server/packs/packs.go

Length of output: 639

api/yorkie/v1/resources.proto (2)

68-69: LGTM! Verify the handling of the new message.

The VersionVector message is newly added. Ensure that this message is handled correctly in the codebase.

Verification successful

LGTM! The VersionVector message is handled correctly across the codebase.

The search results indicate that VersionVector is integrated and used appropriately in various contexts, including initialization, serialization, deserialization, and operations. The presence of tests further confirms its correct handling.

  • pkg/document/document_test.go
  • pkg/document/internal_document.go
  • pkg/document/time/vection_vector.go
  • server/rpc/admin_server.go
  • server/rpc/testcases/testcases.go
  • pkg/document/change/pack.go
  • server/packs/serverpacks.go
  • server/backend/database/change_info.go
  • server/backend/database/snapshot_info.go
  • server/backend/database/mongo/registry.go
  • server/backend/database/memory/database.go
  • admin/client.go
  • api/yorkie/v1/resources.proto
  • api/converter/to_pb.go
  • api/converter/from_pb.go
  • api/docs/yorkie/v1/resources.openapi.yaml
  • api/docs/yorkie/v1/yorkie.openapi.yaml
  • api/docs/yorkie/v1/admin.openapi.yaml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `VersionVector` handle the new message correctly.

# Test: Search for the message usage. Expect: Proper handling of the new message.
rg --type proto -A 5 $'VersionVector'

Length of output: 66


Script:

#!/bin/bash
# Description: Verify all usages of `VersionVector` handle the new message correctly.

# Test: Search for the message usage. Expect: Proper handling of the new message.
rg -A 5 'VersionVector'

Length of output: 47750


65-66: LGTM! Verify the handling of the new field.

The ChangeID message has a new field: VersionVector version_vector. Ensure that this field is handled correctly in the codebase.

Verification successful

The new VersionVector field in ChangeID is handled correctly.

The rg results show that the VersionVector field is used appropriately in various parts of the codebase, including test cases and conversion functions.

  • server/rpc/testcases/testcases.go
  • server/packs/serverpacks.go
  • api/converter/from_pb.go
  • api/converter/to_pb.go
  • api/yorkie/v1/resources.proto
  • api/docs/yorkie/v1/resources.openapi.yaml
  • api/docs/yorkie/v1/yorkie.openapi.yaml
  • api/docs/yorkie/v1/admin.openapi.yaml
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `ChangeID` handle the new field correctly.

# Test: Search for the message usage. Expect: Proper handling of the new field.
rg --type proto -A 5 $'ChangeID'

Length of output: 61


Script:

#!/bin/bash
# Description: Verify all usages of `ChangeID` handle the new field correctly.

# Test 1: Search for the message usage in all files. Expect: Proper handling of the new field.
rg -A 5 $'ChangeID'

# Test 2: Use ast-grep to search for `ChangeID` in the codebase.
ast-grep --lang proto --pattern $'message ChangeID { $$$ }'

Length of output: 14450

server/rpc/admin_server.go (1)

265-273: LGTM! Verify the handling of the new field.

The GetSnapshotMeta function has been updated to handle VersionVector in the response. Ensure that this field is handled correctly in the codebase.

Verification successful

Verify the handling of the VersionVector field in the client code and protobuf definitions.

The GetSnapshotMeta function has been updated to handle VersionVector in the response. Ensure that this field is handled correctly in the client code and that the protobuf definitions are consistent.


Verification Successful: VersionVector field is handled correctly.

The GetSnapshotMeta function has been updated to handle VersionVector in the response. The client code and protobuf definitions are consistent and correctly handle the VersionVector field.

  • admin/client.go: Proper handling of the VersionVector field.
  • api/yorkie/v1/admin.pb.go: Consistent protobuf definitions for VersionVector.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `GetSnapshotMeta` handle the new field correctly.

# Test: Search for the function usage. Expect: Proper handling of the new field.
rg --type go -A 5 $'GetSnapshotMeta'

Length of output: 16542


Script:

#!/bin/bash
# Description: Verify the handling of the `VersionVector` field in the client code and protobuf definitions.

# Test: Search for the handling of the `VersionVector` field in the client code. Expect: Proper handling of the field.
rg --type go -A 5 'VersionVector' admin/client.go

# Test: Verify the protobuf definitions for consistency. Expect: Consistent definitions for `VersionVector`.
rg --type go -A 5 'VersionVector' api/yorkie/v1/admin.pb.go

Length of output: 1560

pkg/document/internal_document.go (4)

149-149: LGTM! Verify the handling of the new field.

The ApplyChangePack method has been updated to handle SnapshotVersionVector. Ensure that this field is handled correctly in the codebase.

Verification successful

Verified: The SnapshotVersionVector is handled correctly in the applySnapshot method within the ApplyChangePack implementation.

  • The applySnapshot method in pkg/document/internal_document.go sets the changeID clocks using the SnapshotVersionVector, ensuring proper handling of the new field.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `ApplyChangePack` handle the new field correctly.

# Test: Search for the method usage. Expect: Proper handling of the new field.
rg --type go -A 5 $'ApplyChangePack'

Length of output: 5959


Script:

#!/bin/bash
# Description: Verify the implementation and usage of `applySnapshot` method to ensure `SnapshotVersionVector` is handled correctly.

# Search for the definition of `applySnapshot` method.
ast-grep --lang go --pattern 'func (d *$_) applySnapshot($_, $_, $_) $_' 

# Search for all usages of `applySnapshot` method.
rg --type go -A 5 'applySnapshot'

Length of output: 2285


223-226: LGTM! Verify the handling of the new method.

The VersionVector method is newly added. Ensure that this method is handled correctly in the codebase.

Verification successful

The VersionVector method is correctly integrated and handled across the codebase.

The new method VersionVector is used in various contexts such as snapshot handling, change application, and protobuf conversions, and appears to be correctly integrated.

  • server/packs/snapshots.go
  • server/packs/pushpull.go
  • server/rpc/testcases/testcases.go
  • server/rpc/admin_server.go
  • server/packs/packs.go
  • server/backend/database/change_info.go
  • server/backend/database/snapshot_info.go
  • server/packs/serverpacks.go
  • server/backend/database/mongo/registry_test.go
  • server/backend/database/memory/database.go
  • pkg/document/internal_document.go
  • pkg/document/document.go
  • pkg/document/document_test.go
  • pkg/document/time/vection_vector.go
  • pkg/document/change/pack.go
  • pkg/document/change/id.go
  • api/converter/to_pb.go
  • api/yorkie/v1/admin.pb.go
  • api/converter/from_pb.go
  • api/yorkie/v1/resources.pb.go
  • admin/client.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `VersionVector` handle the new method correctly.

# Test: Search for the method usage. Expect: Proper handling of the new method.
rg --type go -A 5 $'VersionVector'

Length of output: 39880


Line range hint 111-126:
LGTM! Verify the handling of the new parameter.

The NewInternalDocumentFromSnapshot method has been updated to include a VersionVector parameter. Ensure that this parameter is handled correctly in the codebase.

Verification successful

Verified: The VersionVector parameter is handled correctly.

The NewInternalDocumentFromSnapshot method correctly passes the VersionVector parameter in all identified usages:

  • server/packs/packs.go
  • server/packs/snapshots.go
  • admin/client.go

No issues found in the handling of the new parameter.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `NewInternalDocumentFromSnapshot` handle the new parameter correctly.

# Test: Search for the method usage. Expect: Proper handling of the new parameter.
rg --type go -A 5 $'NewInternalDocumentFromSnapshot'

Length of output: 1398


Script:

#!/bin/bash
# Verify the context around the usages of `NewInternalDocumentFromSnapshot` to ensure the correct `VersionVector` is passed.

# Inspect the usage in server/packs/packs.go
rg --type go -A 10 -B 10 'NewInternalDocumentFromSnapshot' server/packs/packs.go

# Inspect the usage in server/packs/snapshots.go
rg --type go -A 10 -B 10 'NewInternalDocumentFromSnapshot' server/packs/snapshots.go

# Inspect the usage in admin/client.go
rg --type go -A 10 -B 10 'NewInternalDocumentFromSnapshot' admin/client.go

Length of output: 1309


248-258: LGTM! Verify the handling of the new parameter.

The applySnapshot method has been updated to include a VersionVector parameter. Ensure that this parameter is handled correctly in the codebase.

Verification successful

LGTM! Verify the handling of the new parameter.

The applySnapshot method has been updated to include a VersionVector parameter. The SnapshotVersionVector is correctly instantiated and used across the codebase, ensuring proper handling of the new parameter.

  • server/packs/serverpacks.go
  • pkg/document/change/pack.go
  • api/yorkie/v1/resources.pb.go
  • server/packs/pushpull.go
  • pkg/document/document_test.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all usages of `applySnapshot` handle the new parameter correctly.

# Test: Search for the method usage. Expect: Proper handling of the new parameter.
rg --type go -A 5 $'applySnapshot'

Length of output: 1233


Script:

#!/bin/bash
# Description: Verify the definition and usage of `SnapshotVersionVector`

# Search for the definition of `SnapshotVersionVector`
rg --type go 'SnapshotVersionVector'

# Search for the instantiation of `SnapshotVersionVector`
rg --type go 'SnapshotVersionVector ='

Length of output: 1717

pkg/document/document.go (2)

188-188: Verify the handling of SnapshotVersionVector.

Ensure that the SnapshotVersionVector is correctly handled and integrated with the existing logic in applySnapshot.


296-299: LGTM! Ensure the integration of the new method.

The new method VersionVector looks good. Ensure that it is correctly integrated and used in the codebase.

api/converter/to_pb.go (2)

158-170: Verify the handling of VersionVector in ToChangeID.

Ensure that the VersionVector is correctly handled and integrated with the existing logic in ToChangeID.


172-186: LGTM! Ensure the integration of the new method.

The new method ToVersionVector looks good. Ensure that it is correctly integrated and used in the codebase.

pkg/document/document_test.go (2)

571-571: Verify the handling of SnapshotVersionVector in the test case.

Ensure that the SnapshotVersionVector is correctly handled and integrated with the existing logic in the test case.


585-641: LGTM! Ensure the coverage of the new test case.

The new test case version vector test looks good. Ensure that it provides adequate coverage for version vectors.

api/converter/from_pb.go (3)

105-121: Correctly handle Snapshot and SnapshotVersionVector.

The changes correctly handle the Snapshot and SnapshotVersionVector fields. Ensure that the SnapshotVersionVector is properly validated and used in the rest of the codebase.


159-170: Correctly handle VersionVector in fromChangeID.

The changes correctly handle the VersionVector field in the fromChangeID function. Ensure that the VersionVector is properly validated and used in the rest of the codebase.


174-192: New function FromVersionVector correctly converts Protobuf VersionVector to model format.

The function correctly converts the VersionVector and handles potential errors. The TODO comment regarding old clients is noted.

server/rpc/testcases/testcases.go (1)

Line range hint 311-366:
Correctly handle VersionVector in RunPushPullChangeTest.

The changes correctly handle the VersionVector field in the RunPushPullChangeTest function. Ensure that the test cases cover all relevant scenarios for VersionVector.

server/backend/database/memory/database.go (5)

850-851: Addition of VersionVector to ChangeInfo.

The VersionVector field has been added to the ChangeInfo struct. Ensure that this field is correctly populated and utilized in other parts of the code.


1014-1020: Addition of VersionVector to SnapshotInfo.

The VersionVector field has been added to the SnapshotInfo struct. Ensure that this field is correctly populated and utilized in other parts of the code.


1075-1080: Addition of VersionVector to SnapshotInfo.

The VersionVector field has been added to the SnapshotInfo struct. Ensure that this field is correctly populated and utilized in other parts of the code.


1091-1093: Initialization of SnapshotInfo with VersionVector.

A new SnapshotInfo struct is initialized with a VersionVector. Ensure that this initialization is correct and consistent with the rest of the code.


Line range hint 1128-1173:
Addition of UpdateAndFindMinSyncedTime function.

The new function UpdateAndFindMinSyncedTime includes handling for VersionVector. Ensure that the function logic is correct and the VersionVector is correctly utilized.

server/backend/database/mongo/client.go (3)

844-844: LGTM! Added version_vector field to CreateChangeInfos.

The addition of the version_vector field aligns with the PR's objective to handle version vectors for changes.


998-1004: LGTM! Added version_vector field to CreateSnapshotInfo.

The addition of the version_vector field aligns with the PR's objective to handle version vectors for snapshots.


1063-1063: LGTM! Initialized version_vector in FindClosestSnapshotInfo.

The initialization of the version_vector field ensures that it is always set, even when no snapshot is found.

api/docs/yorkie/v1/resources.openapi.yaml (24)

19-22: Ensure schema references are correct.

The schema references for connect.error are consistent and correctly updated.


31-47: Ensure enum values are correct and consistent.

The enum values for connect.error are correctly updated and consistent with the documentation.


Line range hint 166-185:
Ensure properties are correctly updated for yorkie.v1.Change.

The properties for yorkie.v1.Change are correctly updated to include the new VersionVector feature.


211-226: Ensure properties are correctly updated for yorkie.v1.ChangeID.

The properties for yorkie.v1.ChangeID are correctly updated to include the new VersionVector feature.


Line range hint 239-282:
Ensure properties are correctly updated for yorkie.v1.ChangePack.

The properties for yorkie.v1.ChangePack are correctly updated to include the new VersionVector feature.


298-299: Ensure properties are correctly updated for yorkie.v1.Checkpoint.

The properties for yorkie.v1.Checkpoint are correctly updated and consistent with the new VersionVector feature.


Line range hint 308-319:
Ensure properties are correctly updated for yorkie.v1.DocEvent.

The properties for yorkie.v1.DocEvent are correctly updated and consistent with the new VersionVector feature.


345-352: Ensure enum values are correct and consistent.

The enum values for yorkie.v1.DocEventType are correctly updated and consistent with the documentation.


Line range hint 360-387:
Ensure properties are correctly updated for yorkie.v1.DocumentSummary.

The properties for yorkie.v1.DocumentSummary are correctly updated and consistent with the new VersionVector feature.


Line range hint 399-496:
Ensure properties are correctly updated for yorkie.v1.JSONElement.

The properties for yorkie.v1.JSONElement are correctly updated and consistent with the new VersionVector feature.


Line range hint 508-528:
Ensure properties are correctly updated for yorkie.v1.JSONElement.JSONObject.

The properties for yorkie.v1.JSONElement.JSONObject are correctly updated and consistent with the new VersionVector feature.


540-552: Ensure properties are correctly updated for yorkie.v1.JSONElement.Primitive.

The properties for yorkie.v1.JSONElement.Primitive are correctly updated and consistent with the new VersionVector feature.


Line range hint 575-595:
Ensure properties are correctly updated for yorkie.v1.JSONElement.Text.

The properties for yorkie.v1.JSONElement.Text are correctly updated and consistent with the new VersionVector feature.


Line range hint 607-627:
Ensure properties are correctly updated for yorkie.v1.JSONElement.Tree.

The properties for yorkie.v1.JSONElement.Tree are correctly updated and consistent with the new VersionVector feature.


639-651: Ensure properties are correctly updated for yorkie.v1.JSONElementSimple.

The properties for yorkie.v1.JSONElementSimple are correctly updated and consistent with the new VersionVector feature.


Line range hint 679-684:
Ensure properties are correctly updated for yorkie.v1.NodeAttr.

The properties for yorkie.v1.NodeAttr are correctly updated and consistent with the new VersionVector feature.


696-750: Ensure properties are correctly updated for yorkie.v1.Operation.

The properties for yorkie.v1.Operation are correctly updated and consistent with the new VersionVector feature.


Line range hint 762-999:
Ensure properties are correctly updated for Operation subtypes.

The properties for various Operation subtypes are correctly updated and consistent with the new VersionVector feature.


1021-1039: Ensure properties are correctly updated for yorkie.v1.Operation.Style.

The properties for yorkie.v1.Operation.Style are correctly updated and consistent with the new VersionVector feature.


Line range hint 1087-1120:
Ensure properties are correctly updated for yorkie.v1.Operation.TreeEdit.

The properties for yorkie.v1.Operation.TreeEdit are correctly updated and consistent with the new VersionVector feature.


1166-1184: Ensure properties are correctly updated for yorkie.v1.Operation.TreeStyle.

The properties for yorkie.v1.Operation.TreeStyle are correctly updated and consistent with the new VersionVector feature.


1256-1262: Ensure properties are correctly updated for yorkie.v1.PresenceChange.

The properties for yorkie.v1.PresenceChange are correctly updated and consistent with the new VersionVector feature.


Line range hint 1303-1329:
Ensure properties are correctly updated for yorkie.v1.Project.

The properties for yorkie.v1.Project are correctly updated and consistent with the new VersionVector feature.


1341-1347: Ensure properties are correctly updated for yorkie.v1.RGANode.

The properties for yorkie.v1.RGANode are correctly updated and consistent with the new VersionVector feature.

api/docs/yorkie/v1/admin.openapi.yaml (4)

612-617: LGTM! Addition of versionVector property in ChangeID schema.

The addition of the versionVector property in the ChangeID schema looks correct and aligns with the PR objectives.


805-810: LGTM! Addition of versionVector property in GetSnapshotMetaResponse schema.

The addition of the versionVector property in the GetSnapshotMetaResponse schema looks correct and aligns with the PR objectives.


2036-2064: LGTM! Addition of VersionVector schema.

The addition of the new VersionVector schema looks correct and aligns with the PR objectives. The schema is well-defined with appropriate properties.


557-557: LGTM! Update to include ChangeID schema reference in Change schema.

The update to include a reference to the ChangeID schema in the Change schema looks correct and aligns with the PR objectives.

test/integration/gc_test.go Outdated Show resolved Hide resolved
pkg/document/crdt/root_test.go Outdated Show resolved Hide resolved
Copy link

coderabbitai bot commented Jul 15, 2024

Actions performed

Reviews resumed.

Copy link

coderabbitai bot commented Jul 15, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

Commits

Files that changed from the base of the PR and between b468f8b and c815a09.

Files ignored due to path filters (2)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
  • api/yorkie/v1/resources.pb.go is excluded by !**/*.pb.go
Files selected for processing (32)
  • admin/client.go (1 hunks)
  • api/converter/from_pb.go (2 hunks)
  • api/converter/to_pb.go (2 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (53 hunks)
  • api/docs/yorkie/v1/resources.openapi.yaml (63 hunks)
  • api/docs/yorkie/v1/yorkie.openapi.yaml (49 hunks)
  • api/yorkie/v1/admin.proto (1 hunks)
  • api/yorkie/v1/resources.proto (2 hunks)
  • pkg/document/change/change.go (1 hunks)
  • pkg/document/change/id.go (5 hunks)
  • pkg/document/change/pack.go (2 hunks)
  • pkg/document/crdt/root_test.go (1 hunks)
  • pkg/document/document.go (2 hunks)
  • pkg/document/document_test.go (3 hunks)
  • pkg/document/internal_document.go (8 hunks)
  • pkg/document/time/actor_id.go (1 hunks)
  • pkg/document/time/ticket.go (1 hunks)
  • pkg/document/time/vection_vector.go (1 hunks)
  • server/backend/database/change_info.go (2 hunks)
  • server/backend/database/database.go (1 hunks)
  • server/backend/database/memory/database.go (7 hunks)
  • server/backend/database/mongo/client.go (5 hunks)
  • server/backend/database/mongo/registry.go (3 hunks)
  • server/backend/database/mongo/registry_test.go (1 hunks)
  • server/backend/database/snapshot_info.go (3 hunks)
  • server/packs/packs.go (3 hunks)
  • server/packs/pushpull.go (1 hunks)
  • server/packs/serverpacks.go (3 hunks)
  • server/packs/snapshots.go (1 hunks)
  • server/rpc/admin_server.go (1 hunks)
  • server/rpc/testcases/testcases.go (4 hunks)
  • test/integration/gc_test.go (1 hunks)
________________________________
< Overly attached code reviewer. >
--------------------------------
 \
  \   (\__/)
      (•ㅅ•)
      /   づ

Tip

You can make CodeRabbit's review more strict using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting in your project's settings in CodeRabbit to assertive to make CodeRabbit's nitpick more issues in your PRs.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (1)
server/backend/database/memory/database.go (1)

Line range hint 1128-1173: Necessary function signature change and TODO comment.

The function signature change is necessary to accommodate the new return type. The TODO comment indicates that further work is needed to build the version vector.

Do you want me to help with building the version vector or open a GitHub issue to track this task?

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b468f8b and c815a09.

Files ignored due to path filters (2)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
  • api/yorkie/v1/resources.pb.go is excluded by !**/*.pb.go
Files selected for processing (32)
  • admin/client.go (1 hunks)
  • api/converter/from_pb.go (2 hunks)
  • api/converter/to_pb.go (2 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (53 hunks)
  • api/docs/yorkie/v1/resources.openapi.yaml (63 hunks)
  • api/docs/yorkie/v1/yorkie.openapi.yaml (49 hunks)
  • api/yorkie/v1/admin.proto (1 hunks)
  • api/yorkie/v1/resources.proto (2 hunks)
  • pkg/document/change/change.go (1 hunks)
  • pkg/document/change/id.go (5 hunks)
  • pkg/document/change/pack.go (2 hunks)
  • pkg/document/crdt/root_test.go (1 hunks)
  • pkg/document/document.go (2 hunks)
  • pkg/document/document_test.go (3 hunks)
  • pkg/document/internal_document.go (8 hunks)
  • pkg/document/time/actor_id.go (1 hunks)
  • pkg/document/time/ticket.go (1 hunks)
  • pkg/document/time/vection_vector.go (1 hunks)
  • server/backend/database/change_info.go (2 hunks)
  • server/backend/database/database.go (1 hunks)
  • server/backend/database/memory/database.go (7 hunks)
  • server/backend/database/mongo/client.go (5 hunks)
  • server/backend/database/mongo/registry.go (3 hunks)
  • server/backend/database/mongo/registry_test.go (1 hunks)
  • server/backend/database/snapshot_info.go (3 hunks)
  • server/packs/packs.go (3 hunks)
  • server/packs/pushpull.go (1 hunks)
  • server/packs/serverpacks.go (3 hunks)
  • server/packs/snapshots.go (1 hunks)
  • server/rpc/admin_server.go (1 hunks)
  • server/rpc/testcases/testcases.go (4 hunks)
  • test/integration/gc_test.go (1 hunks)
Files not summarized due to errors (2)
  • api/docs/yorkie/v1/admin.openapi.yaml: Error: Message exceeds token limit
  • api/docs/yorkie/v1/yorkie.openapi.yaml: Error: Message exceeds token limit
Files skipped from review due to trivial changes (1)
  • pkg/document/crdt/root_test.go
Files skipped from review as they are similar to previous changes (23)
  • admin/client.go
  • api/converter/from_pb.go
  • api/converter/to_pb.go
  • api/docs/yorkie/v1/resources.openapi.yaml
  • api/yorkie/v1/admin.proto
  • api/yorkie/v1/resources.proto
  • pkg/document/change/change.go
  • pkg/document/change/id.go
  • pkg/document/change/pack.go
  • pkg/document/document.go
  • pkg/document/internal_document.go
  • pkg/document/time/actor_id.go
  • pkg/document/time/vection_vector.go
  • server/backend/database/change_info.go
  • server/backend/database/mongo/client.go
  • server/backend/database/mongo/registry_test.go
  • server/backend/database/snapshot_info.go
  • server/packs/packs.go
  • server/packs/pushpull.go
  • server/packs/serverpacks.go
  • server/packs/snapshots.go
  • server/rpc/testcases/testcases.go
  • test/integration/gc_test.go
Additional comments not posted (76)
pkg/document/time/ticket.go (1)

50-53: LGTM!

The comments provide clarity on the purpose and limitations of the Ticket struct.

server/backend/database/mongo/registry.go (4)

27-31: LGTM!

The new imports are necessary for handling VersionVector encoding and decoding.


37-37: LGTM!

The new variable is necessary for registering the VersionVector type with the BSON codec registry.


52-52: LGTM!

The decoder registration is necessary for decoding VersionVector from BSON.


57-57: LGTM!

The encoder registration is necessary for encoding VersionVector to BSON.

server/backend/database/database.go (1)

249-256: LGTM!

The changes to the UpdateAndFindMinSyncedTime method are necessary to support the new VersionVector functionality.

server/rpc/admin_server.go (1)

265-273: LGTM!

The changes to the GetSnapshotMeta method are necessary to include the VersionVector in the response.

pkg/document/document_test.go (2)

571-571: LGTM!

The inclusion of SnapshotVersionVector in the change pack is a good addition to maintain version consistency.


585-641: Well-structured tests for version vector functionality.

The tests comprehensively cover the creation, update, and verification of version vectors, including causal relationships and concurrent updates.

server/backend/database/memory/database.go (1)

850-851: Good addition of VersionVector to change info.

The inclusion of VersionVector in the change info is crucial for accurate change tracking.

api/docs/yorkie/v1/yorkie.openapi.yaml (61)

3-3: Ensure the description is accurate and complete.

The description provides a brief overview of the Yorkie service. Verify that it accurately reflects the current state of the service.


8-11: Verify server URLs.

Ensure that the URLs for the production and local servers are correct and accessible.


17-17: Check the request body reference.

Ensure that the reference to ActivateClientRequest is correct and the schema is defined in the components section.


20-22: Check the response references.

Ensure that the references to ActivateClientResponse and connect.error are correct and the schemas are defined in the components section.


24-24: Verify the tag.

Ensure that the tag yorkie.v1.YorkieService is correctly defined and used consistently across the API specification.


115-118: Check the schema reference for ActivateClientRequest.

Ensure that the schema for ActivateClientRequest is correctly defined and referenced.


124-127: Check the schema reference for AttachDocumentRequest.

Ensure that the schema for AttachDocumentRequest is correctly defined and referenced.


133-136: Check the schema reference for BroadcastRequest.

Ensure that the schema for BroadcastRequest is correctly defined and referenced.


142-145: Check the schema reference for DeactivateClientRequest.

Ensure that the schema for DeactivateClientRequest is correctly defined and referenced.


151-154: Check the schema reference for DetachDocumentRequest.

Ensure that the schema for DetachDocumentRequest is correctly defined and referenced.


160-163: Check the schema reference for PushPullChangesRequest.

Ensure that the schema for PushPullChangesRequest is correctly defined and referenced.


169-172: Check the schema reference for RemoveDocumentRequest.

Ensure that the schema for RemoveDocumentRequest is correctly defined and referenced.


182-185: Check the schema reference for connect.error.

Ensure that the schema for connect.error is correctly defined and referenced.


191-194: Check the schema reference for ActivateClientResponse.

Ensure that the schema for ActivateClientResponse is correctly defined and referenced.


200-203: Check the schema reference for AttachDocumentResponse.

Ensure that the schema for AttachDocumentResponse is correctly defined and referenced.


209-212: Check the schema reference for BroadcastResponse.

Ensure that the schema for BroadcastResponse is correctly defined and referenced.


218-221: Check the schema reference for DeactivateClientResponse.

Ensure that the schema for DeactivateClientResponse is correctly defined and referenced.


227-230: Check the schema reference for DetachDocumentResponse.

Ensure that the schema for DetachDocumentResponse is correctly defined and referenced.


236-239: Check the schema reference for PushPullChangesResponse.

Ensure that the schema for PushPullChangesResponse is correctly defined and referenced.


245-248: Check the schema reference for RemoveDocumentResponse.

Ensure that the schema for RemoveDocumentResponse is correctly defined and referenced.


255-275: Verify the connect.error schema.

Ensure that the connect.error schema is correctly defined and includes all necessary properties and examples.


308-310: Check the schema reference for ChangePack in AttachDocumentRequest.

Ensure that the schema for ChangePack is correctly defined and referenced.


325-327: Check the schema reference for ChangePack in AttachDocumentResponse.

Ensure that the schema for ChangePack is correctly defined and referenced.


Line range hint 374-388:
Check the schema reference for ChangeID in Change.

Ensure that the schema for ChangeID is correctly defined and referenced.


419-434: Verify the ChangeID schema.

Ensure that the ChangeID schema is correctly defined and includes the new versionVector property.


Line range hint 447-490:
Verify the ChangePack schema.

Ensure that the ChangePack schema is correctly defined and includes the new minSyncedVersionVector and snapshotVersionVector properties.


506-507: Check the schema reference for server_seq in Checkpoint.

Ensure that the schema for server_seq is correctly defined and referenced.


532-533: Check the schema reference for ChangePack in DetachDocumentRequest.

Ensure that the schema for ChangePack is correctly defined and referenced.


559-559: Check the schema reference for ChangePack in DetachDocumentResponse.

Ensure that the schema for ChangePack is correctly defined and referenced.


Line range hint 571-582:
Verify the DocEvent schema.

Ensure that the DocEvent schema is correctly defined and includes all necessary properties.


608-615: Verify the DocEventType schema.

Ensure that the DocEventType schema is correctly defined and includes all necessary enum values.


623-641: Check the schema references in JSONElementSimple.

Ensure that the schemas for createdAt, movedAt, removedAt, and type are correctly defined and referenced.


663-663: Check the schema reference for updated_at in NodeAttr.

Ensure that the schema for updated_at is correctly defined and referenced.


680-734: Verify the Operation schema and its nested schemas.

Ensure that the Operation schema and its nested schemas (Add, Edit, Increase, Move, Remove, Select, Set, Style, TreeEdit, TreeStyle) are correctly defined and include all necessary properties.


746-764: Check the schema reference for JSONElementSimple in Operation.Add.

Ensure that the schema for JSONElementSimple is correctly defined and referenced.


791-809: Check the schema references in Operation.Edit.

Ensure that the schemas for executed_at, from, and to are correctly defined and referenced.


854-866: Check the schema reference for JSONElementSimple in Operation.Increase.

Ensure that the schema for JSONElementSimple is correctly defined and referenced.


878-896: Check the schema references in Operation.Move.

Ensure that the schemas for created_at, executed_at, parent_created_at, and prev_created_at are correctly defined and referenced.


908-920: Check the schema references in Operation.Remove.

Ensure that the schemas for created_at, executed_at, and parent_created_at are correctly defined and referenced.


936-954: Check the schema references in Operation.Select.

Ensure that the schemas for executed_at, from, parent_created_at, and to are correctly defined and referenced.


Line range hint 966-983:
Check the schema references in Operation.Set.

Ensure that the schemas for executed_at, parent_created_at, and JSONElementSimple are correctly defined and referenced.


1005-1023: Check the schema references in Operation.Style.

Ensure that the schemas for executed_at, from, parent_created_at, and to are correctly defined and referenced.


Line range hint 1071-1104:
Check the schema references in Operation.TreeEdit.

Ensure that the schemas for contents, created_at_map_by_actor, executed_at, from, parent_created_at, and to are correctly defined and referenced.


1150-1168: Check the schema references in Operation.TreeStyle.

Ensure that the schemas for executed_at, from, parent_created_at, and to are correctly defined and referenced.


1201-1201: Check the schema reference for TimeTicket in Operation.TreeStyle.CreatedAtMapByActorEntry.

Ensure that the schema for TimeTicket is correctly defined and referenced.


1240-1246: Check the schema references in PresenceChange.

Ensure that the schemas for presence and type are correctly defined and referenced.


1270-1270: Check the schema reference for ChangePack in PushPullChangesRequest.

Ensure that the schema for ChangePack is correctly defined and referenced.


1297-1297: Check the schema reference for ChangePack in PushPullChangesResponse.

Ensure that the schema for ChangePack is correctly defined and referenced.


1309-1309: Check the schema reference for ChangePack in RemoveDocumentRequest.

Ensure that the schema for ChangePack is correctly defined and referenced.


1331-1331: Check the schema reference for ChangePack in RemoveDocumentResponse.

Ensure that the schema for ChangePack is correctly defined and referenced.


1343-1343: Check the schema reference for TimeTicket in TextNodePos.

Ensure that the schema for TimeTicket is correctly defined and referenced.


1399-1417: Check the schema references in TreeNode.

Ensure that the schemas for id, ins_next_id, ins_prev_id, and removed_at are correctly defined and referenced.


1444-1444: Check the schema reference for NodeAttr in TreeNode.AttributesEntry.

Ensure that the schema for NodeAttr is correctly defined and referenced.


1456-1456: Check the schema reference for TimeTicket in TreeNodeID.

Ensure that the schema for TimeTicket is correctly defined and referenced.


1476-1476: Check the schema reference for TreeNode in TreeNodes.

Ensure that the schema for TreeNode is correctly defined and referenced.


1487-1493: Check the schema references in TreePos.

Ensure that the schemas for left_sibling_id and parent_id are correctly defined and referenced.


1503-1530: Verify the ValueType schema.

Ensure that the ValueType schema is correctly defined and includes all necessary enum values.


1534-1561: Verify the VersionVector schema.

Ensure that the VersionVector schema is correctly defined and includes all necessary properties and nested schemas.


1583-1589: Check the schema references in WatchDocumentResponse.

Ensure that the schemas for event and initialization are correctly defined and referenced.


1615-1615: Check the security scheme reference for ApiKeyAuth.

Ensure that the security scheme for ApiKeyAuth is correctly defined and referenced.


1617-1618: Verify the tag description.

Ensure that the tag description for yorkie.v1.YorkieService is accurate and complete.

api/docs/yorkie/v1/admin.openapi.yaml (5)

3-3: LGTM!

The updated description of the Yorkie API is clear and concise.


8-11: LGTM!

The updated server URLs for the Yorkie API are correctly specified.


557-557: LGTM!

The Change schema now correctly references the yorkie.v1.ChangeID schema.


612-617: LGTM!

The ChangeID schema now includes a versionVector field, aligning with the PR's objective.


805-810: LGTM!

The GetSnapshotMetaResponse schema now includes a versionVector field, aligning with the PR's objective.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
server/rpc/testcases/testcases.go (1)

Insufficient test coverage for VersionVector

The current implementation only includes VersionVector in a single test case within server/rpc/testcases/testcases.go. To ensure comprehensive coverage of the new VersionVector functionality, it is recommended to add more test cases that cover various scenarios involving VersionVector.

  • File: server/rpc/testcases/testcases.go
  • Lines: 318-327
Analysis chain

Line range hint 311-366: Integration of VersionVector in test cases.

The test cases have been updated to include VersionVector in the ChangePack. This is crucial for testing the new functionality related to version tracking and synchronization. The changes are correctly implemented and should help ensure that the system behaves as expected when handling VersionVector.

Ensure that these test cases cover all relevant scenarios and that the VersionVector functionality is thoroughly tested.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the coverage of VersionVector-related test cases.

# Test: Search for test cases involving VersionVector. Expect: Comprehensive coverage of VersionVector scenarios.
rg --type go "VersionVector" server/rpc/testcases/testcases.go

Length of output: 222


Script:

#!/bin/bash
# Description: Verify the coverage of VersionVector-related test cases across all test files.

# Test: Search for test cases involving VersionVector in all test files within the server/rpc/testcases/ directory.
rg --type go "VersionVector" server/rpc/testcases/

Length of output: 346

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c815a09 and 93c192b.

Files ignored due to path filters (2)
  • api/yorkie/v1/admin.pb.go is excluded by !**/*.pb.go
  • api/yorkie/v1/resources.pb.go is excluded by !**/*.pb.go
Files selected for processing (31)
  • admin/client.go (1 hunks)
  • api/converter/from_pb.go (2 hunks)
  • api/converter/to_pb.go (2 hunks)
  • api/docs/yorkie/v1/admin.openapi.yaml (53 hunks)
  • api/docs/yorkie/v1/resources.openapi.yaml (63 hunks)
  • api/docs/yorkie/v1/yorkie.openapi.yaml (49 hunks)
  • api/yorkie/v1/admin.proto (1 hunks)
  • api/yorkie/v1/resources.proto (2 hunks)
  • pkg/document/change/change.go (1 hunks)
  • pkg/document/change/id.go (5 hunks)
  • pkg/document/change/pack.go (2 hunks)
  • pkg/document/document.go (2 hunks)
  • pkg/document/document_test.go (3 hunks)
  • pkg/document/internal_document.go (8 hunks)
  • pkg/document/time/actor_id.go (1 hunks)
  • pkg/document/time/ticket.go (1 hunks)
  • pkg/document/time/vection_vector.go (1 hunks)
  • server/backend/database/change_info.go (2 hunks)
  • server/backend/database/database.go (1 hunks)
  • server/backend/database/memory/database.go (7 hunks)
  • server/backend/database/mongo/client.go (5 hunks)
  • server/backend/database/mongo/registry.go (3 hunks)
  • server/backend/database/mongo/registry_test.go (1 hunks)
  • server/backend/database/snapshot_info.go (3 hunks)
  • server/packs/packs.go (3 hunks)
  • server/packs/pushpull.go (1 hunks)
  • server/packs/serverpacks.go (3 hunks)
  • server/packs/snapshots.go (1 hunks)
  • server/rpc/admin_server.go (1 hunks)
  • server/rpc/testcases/testcases.go (4 hunks)
  • test/integration/gc_test.go (1 hunks)
Files not summarized due to errors (2)
  • api/docs/yorkie/v1/admin.openapi.yaml: Error: Message exceeds token limit
  • api/docs/yorkie/v1/yorkie.openapi.yaml: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (25)
  • admin/client.go
  • api/converter/from_pb.go
  • api/converter/to_pb.go
  • api/docs/yorkie/v1/resources.openapi.yaml
  • api/yorkie/v1/admin.proto
  • api/yorkie/v1/resources.proto
  • pkg/document/change/change.go
  • pkg/document/change/id.go
  • pkg/document/change/pack.go
  • pkg/document/document.go
  • pkg/document/document_test.go
  • pkg/document/internal_document.go
  • pkg/document/time/actor_id.go
  • pkg/document/time/ticket.go
  • pkg/document/time/vection_vector.go
  • server/backend/database/change_info.go
  • server/backend/database/mongo/client.go
  • server/backend/database/mongo/registry_test.go
  • server/backend/database/snapshot_info.go
  • server/packs/packs.go
  • server/packs/pushpull.go
  • server/packs/serverpacks.go
  • server/packs/snapshots.go
  • server/rpc/admin_server.go
  • test/integration/gc_test.go
Additional comments not posted (15)
server/backend/database/mongo/registry.go (3)

37-37: Addition of tVersionVector type variable.

This line correctly declares a type variable for VersionVector which is used in the registry builder to register the appropriate encoders and decoders. This is a necessary step for handling VersionVector in MongoDB operations.


52-52: Registration of VersionVector encoders and decoders.

The registration of both encoder and decoder for VersionVector ensures that MongoDB can serialize and deserialize these objects correctly. This is essential for the new functionality introduced in the PR.

Also applies to: 57-57


87-107: Implementation of versionVectorEncoder and versionVectorDecoder.

The encoder and decoder functions are implemented to handle VersionVector objects. The encoder converts a VersionVector to a protobuf message and then serializes it to bytes, while the decoder does the reverse. This ensures that VersionVector data is correctly stored and retrieved from MongoDB.

However, ensure that error handling is robust and that all potential edge cases, such as invalid input or serialization failures, are appropriately managed.

Verification successful

Robust error handling in versionVectorEncoder and versionVectorDecoder confirmed.

The error handling in both functions is comprehensive and appropriately addresses potential edge cases, such as invalid input and serialization failures.

  • versionVectorEncoder handles errors when converting to protobuf, serializing to bytes, and writing binary data.
  • versionVectorDecoder handles errors when reading binary data, unmarshalling the protobuf message, and converting back to VersionVector.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for robust error handling in versionVectorEncoder and versionVectorDecoder.

# Test: Search for error handling patterns. Expect: Robust error handling across the functions.
rg --type go -A 5 "if err != nil" server/backend/database/mongo/registry.go

Length of output: 692


Script:

#!/bin/bash
# Extract the full implementation of the versionVectorDecoder function from the file
ast-grep --lang go --pattern $'func versionVectorDecoder($_, $_, $_) error {
  $$$
}' server/backend/database/mongo/registry.go

Length of output: 2086

server/backend/database/database.go (1)

249-256: Updated UpdateAndFindMinSyncedTime function signature.

The function now returns a VersionVector in addition to the Ticket, reflecting the enhanced functionality to track both the minimum synchronized time and version vector. This change is consistent with the PR's objectives to enhance change tracking and synchronization capabilities.

server/backend/database/memory/database.go (4)

850-851: Integrate VersionVector in ChangeInfo struct.

The VersionVector field has been added to the ChangeInfo struct to track the version history of changes, which aligns with the PR's objectives to enhance tracking of causal relationships in distributed systems.


1014-1021: Review the CreateSnapshotInfo function for correct VersionVector handling.

The CreateSnapshotInfo function correctly integrates the VersionVector by storing it with each snapshot. This ensures that each snapshot's state can be correlated with its version history, which is crucial for resolving conflicts in a distributed environment.


1075-1081: Check snapshot retrieval logic for correct VersionVector integration.

The snapshot retrieval logic now includes the VersionVector, which is essential for determining the document state at various points in its history. This change is crucial for the system's ability to revert or merge changes based on their causal relationships.


1091-1093: Ensure fallback for missing snapshots includes an initialized VersionVector.

When no suitable snapshot is found, the system initializes a new SnapshotInfo with an empty VersionVector. This is a safe approach as it prevents potential null reference errors when accessing the version vector of a non-existent snapshot.

api/docs/yorkie/v1/yorkie.openapi.yaml (6)

17-17: Ensure references to request bodies and responses are correctly updated.

All references to request bodies and responses appear to be correctly updated to reflect the new endpoints and functionalities introduced in the API. This includes endpoints like ActivateClient, AttachDocument, Broadcast, etc.

Also applies to: 20-20, 22-22, 24-24, 29-29, 32-32, 34-34, 36-36, 41-41, 44-44, 46-46, 48-48, 53-53, 56-56, 58-58, 60-60, 65-65, 68-68, 70-70, 72-72, 77-77, 80-80, 82-82, 84-84, 89-89, 92-92, 94-94, 96-96, 101-101, 104-104, 106-106, 108-108


115-115: Check schema references for request bodies.

All schema references for request bodies are correctly pointing to their respective definitions under components/schemas. This ensures that the API documentation remains consistent and easy to navigate.

Also applies to: 118-118, 124-124, 127-127, 133-133, 136-136, 142-142, 145-145, 151-151, 154-154, 160-160, 163-163, 169-169, 172-172


182-182: Validate error schema references.

The references to the error schema under components/schemas/connect.error are correctly set up. This is crucial for ensuring that error handling in the API is well-documented and consistent.

Also applies to: 185-185


191-191: Review response schema references for consistency.

All response schema references are correctly pointing to their respective definitions. This consistency in referencing ensures that the API documentation is reliable and accurate.

Also applies to: 194-194, 200-200, 203-203, 209-209, 212-212, 218-218, 221-221, 227-227, 230-230, 236-236, 239-239, 245-245, 248-248


255-255: Update error description to reflect current API standards.

The error description has been updated to provide a link to the Connect RPC documentation. This is a good practice as it directs users to a detailed explanation of error codes and their HTTP representations.


308-308: Comprehensive review of schema references and properties.

All schema references, properties, and type definitions across the document have been checked and are correctly defined. This includes complex nested structures and new additions like VersionVector which are crucial for the new functionalities introduced in the API.

Also applies to: 325-325, 374-374, 388-388, 393-393, 429-429, 447-447, 452-452, 468-468, 473-473, 485-485, 506-506, 532-532, 559-559, 571-571, 582-582, 623-623, 629-629, 635-635, 641-641, 663-663, 680-680, 686-686, 692-692, 698-698, 704-704, 710-710, 716-716, 722-722, 728-728, 734-734, 746-746, 752-752, 758-758, 764-764, 791-791, 797-797, 803-803, 809-809, 842-842, 854-854, 860-860, 866-866, 878-878, 884-884, 890-890, 896-896, 908-908, 914-914, 920-920, 936-936, 942-942, 948-948, 954-954, 966-966, 977-977, 983-983, 1005-1005, 1011-1011, 1017-1017, 1023-1023, 1056-1056, 1071-1071, 1081-1081, 1087-1087, 1093-1093, 1104-1104, 1121-1121, 1150-1150, 1156-1156, 1162-1162, 1168-1168, 1201-1201, 1240-1240, 1246-1246, 1270-1270, 1297-1297, 1309-1309, 1331-1331, 1343-1343, 1379-1379, 1399-1399, 1405-1405, 1411-1411, 1417-1417, 1444-1444, 1456-1456, 1476-1476, 1487-1487, 1493-1493, 1503-1503, 1533-1533, 1583-1583, 1589-1589, 1615-1615, 1617-1617

api/docs/yorkie/v1/admin.openapi.yaml (1)

3-3: Updated API Version Noted

The version update to v0.4.27 is correctly documented.

server/backend/database/memory/database.go Outdated Show resolved Hide resolved
api/docs/yorkie/v1/yorkie.openapi.yaml Outdated Show resolved Hide resolved
@hackerwins hackerwins marked this pull request as draft July 16, 2024 04:31
@hackerwins hackerwins force-pushed the hybrid-clock branch 2 times, most recently from e456507 to f83dc0d Compare July 16, 2024 04:36
@hackerwins hackerwins force-pushed the hybrid-clock branch 8 times, most recently from d4ef095 to fb3a582 Compare July 18, 2024 06:42
@hackerwins hackerwins force-pushed the hybrid-clock branch 2 times, most recently from 46081f7 to adb5e87 Compare September 26, 2024 10:24
Unify VersionVectors in ChangePack across three scenarios:

1. Pushing pack to server: represents document's current version vector
2. Pulling pack: represents minSyncedVersionVector for GC
3. Pulling pack(snapshot): represents snapshot's version vector at creation

This commit simplifies the codebase and ensures consistent version
vector handling throughout the document synchronization process.
* Update garbage collection design document

* Fix typo

* Update version vector design document

* Add contents to garbage collection design document

* Updated explanation based on review feedback

* Updated explanation based on review feedback
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.

2 participants