-
-
Notifications
You must be signed in to change notification settings - Fork 147
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
Changes from 1 commit
c78ffe7
eefccb0
eec25b3
42ca4e2
d267c11
30eaa9f
e30b2a2
88735cc
bb9c7bb
437d83a
5c98c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
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.
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,7 +31,7 @@ func storeSnapshot( | |||||||||
ctx context.Context, | ||||||||||
be *backend.Backend, | ||||||||||
docInfo *database.DocInfo, | ||||||||||
minSyncedTicket *time.Ticket, | ||||||||||
minSyncedVersionVector time.VersionVector, | ||||||||||
) error { | ||||||||||
// 01. get the closest snapshot's metadata of this docInfo | ||||||||||
docRefKey := docInfo.RefKey() | ||||||||||
|
@@ -91,13 +91,19 @@ func storeSnapshot( | |||||||||
nil, | ||||||||||
nil, | ||||||||||
) | ||||||||||
pack.MinSyncedTicket = minSyncedTicket | ||||||||||
|
||||||||||
if err := doc.ApplyChangePack(pack, be.Config.SnapshotDisableGC); err != nil { | ||||||||||
return err | ||||||||||
} | ||||||||||
|
||||||||||
// 04. save the snapshot of the docInfo | ||||||||||
// 04. perform garbage collect to remove tombstones | ||||||||||
if !be.Config.SnapshotDisableGC { | ||||||||||
if _, err := doc.GarbageCollect(minSyncedVersionVector); err != nil { | ||||||||||
return err | ||||||||||
} | ||||||||||
Comment on lines
+102
to
+103
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance error messages by wrapping errors with context. When returning errors, consider adding context to the error message to facilitate debugging. Apply this diff: - return err
+ return fmt.Errorf("garbage collection failed: %w", err) Ensure that the 📝 Committable suggestion
Suggested change
|
||||||||||
} | ||||||||||
|
||||||||||
Comment on lines
+99
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add logging after garbage collection for better observability. Including a log statement after a successful garbage collection can aid in monitoring and debugging. Apply this diff to add logging: }
+ logging.From(ctx).Infof(
+ "Garbage collection completed for document '%s'",
+ docInfo.Key,
+ )
// 05. save the snapshot of the docInfo
|
||||||||||
// 05. save the snapshot of the docInfo | ||||||||||
if err := be.DB.CreateSnapshotInfo( | ||||||||||
ctx, | ||||||||||
docRefKey, | ||||||||||
|
@@ -106,7 +112,7 @@ func storeSnapshot( | |||||||||
return err | ||||||||||
} | ||||||||||
|
||||||||||
// 05. delete changes before the smallest in `syncedseqs` to save storage. | ||||||||||
// 06. delete changes before the smallest in `syncedseqs` to save storage. | ||||||||||
if be.Config.SnapshotWithPurgingChanges { | ||||||||||
if err := be.DB.PurgeStaleChanges( | ||||||||||
ctx, | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use Protobuf deprecation option for
min_synced_ticket
Consider using the Protobuf
deprecated
option to formally deprecate themin_synced_ticket
field instead of a comment. This helps code generators provide appropriate warnings.Update the field definition to:
📝 Committable suggestion