From bd886c5572b0be8039b772fbca0a909bcdb73165 Mon Sep 17 00:00:00 2001 From: Yourim Cha <81357083+chacha912@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:38:02 +0900 Subject: [PATCH] Fix ReverseLowerBound behavior in MemDB with unique index (#1074) This change resolves a test failure in the js-sdk caused by an unexpected MemDB search behavior. The issue stems from the `ReverseLowerBound` method behaving differently for unique and non-unique indexes. Key changes: - Set `doc_id_actor_id_server_seq` index as unique - Ensures correct record retrieval in `FindMinSyncedSeqInfo` - Resolves `ConnectError: [internal] change not found` during DetachDocument Addressed a known MemDB limitation where index uniqueness affects search behavior, referencing hashicorp/go-memdb#96. --- server/backend/database/memory/indexes.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/backend/database/memory/indexes.go b/server/backend/database/memory/indexes.go index 4c30d7041..206d6619b 100644 --- a/server/backend/database/memory/indexes.go +++ b/server/backend/database/memory/indexes.go @@ -168,7 +168,8 @@ var schema = &memdb.DBSchema{ }, }, "doc_id_actor_id_server_seq": { - Name: "doc_id_actor_id_server_seq", + Name: "doc_id_actor_id_server_seq", + Unique: true, Indexer: &memdb.CompoundIndex{ Indexes: []memdb.Indexer{ &memdb.StringFieldIndex{Field: "DocID"},