From aea5cd976c4ee2f96b1f825f9db723eb822da767 Mon Sep 17 00:00:00 2001 From: Youngteac Hong Date: Fri, 25 Oct 2024 16:41:53 +0900 Subject: [PATCH] Fix transaction in UpdateAndFindMinSyncedVV --- server/backend/database/database.go | 4 ++-- server/backend/database/memory/database.go | 6 +++--- server/backend/database/mongo/client.go | 4 ++-- server/packs/packs.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/backend/database/database.go b/server/backend/database/database.go index 53e8a8dd1..fb4d0dae8 100644 --- a/server/backend/database/database.go +++ b/server/backend/database/database.go @@ -271,9 +271,9 @@ type Database interface { serverSeq int64, ) (*time.Ticket, error) - // UpdateAndFindMinSyncedVersionVectorAfterPushPull updates the given serverSeq of the given client + // UpdateAndFindMinSyncedVersionVector updates the given serverSeq of the given client // and returns the SyncedVersionVector of the document. - UpdateAndFindMinSyncedVersionVectorAfterPushPull( + UpdateAndFindMinSyncedVersionVector( ctx context.Context, clientInfo *ClientInfo, docRefKey types.DocRefKey, diff --git a/server/backend/database/memory/database.go b/server/backend/database/memory/database.go index e6e656321..98d17d833 100644 --- a/server/backend/database/memory/database.go +++ b/server/backend/database/memory/database.go @@ -1312,9 +1312,9 @@ func (d *DB) UpdateVersionVector( return nil } -// UpdateAndFindMinSyncedVersionVectorAfterPushPull updates the given serverSeq of the given client +// UpdateAndFindMinSyncedVersionVector updates the given serverSeq of the given client // and returns the SyncedVersionVector of the document. -func (d *DB) UpdateAndFindMinSyncedVersionVectorAfterPushPull( +func (d *DB) UpdateAndFindMinSyncedVersionVector( ctx context.Context, clientInfo *database.ClientInfo, docRefKey types.DocRefKey, @@ -1338,7 +1338,7 @@ func (d *DB) UpdateAndFindMinSyncedVersionVectorAfterPushPull( } // 02. Find all version vectors of the given document from DB. - txn := d.db.Txn(true) + txn := d.db.Txn(false) defer txn.Abort() iterator, err := txn.Get(tblVersionVectors, "doc_id", docRefKey.DocID.String()) if err != nil { diff --git a/server/backend/database/mongo/client.go b/server/backend/database/mongo/client.go index 09c37ef7e..29208624d 100644 --- a/server/backend/database/mongo/client.go +++ b/server/backend/database/mongo/client.go @@ -1197,8 +1197,8 @@ func (c *Client) UpdateAndFindMinSyncedTicket( ), nil } -// UpdateAndFindMinSyncedVersionVectorAfterPushPull returns min synced version vector -func (c *Client) UpdateAndFindMinSyncedVersionVectorAfterPushPull( +// UpdateAndFindMinSyncedVersionVector returns min synced version vector +func (c *Client) UpdateAndFindMinSyncedVersionVector( ctx context.Context, clientInfo *database.ClientInfo, docRefKey types.DocRefKey, diff --git a/server/packs/packs.go b/server/packs/packs.go index f39205bb2..ddafe44fd 100644 --- a/server/packs/packs.go +++ b/server/packs/packs.go @@ -132,7 +132,7 @@ func PushPull( // 05. update and find min synced version vector for garbage collection. // NOTE(hackerwins): Since the client could not receive the response, the // requested seq(reqPack) is stored instead of the response seq(resPack). - minSyncedVersionVector, err := be.DB.UpdateAndFindMinSyncedVersionVectorAfterPushPull( + minSyncedVersionVector, err := be.DB.UpdateAndFindMinSyncedVersionVector( ctx, clientInfo, docRefKey,