Skip to content

Commit aa7e8ab

Browse files
authored
fix: RENAME in cluster mode crash (#4995)
fixed: #4993
1 parent 0f415ac commit aa7e8ab

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/server/generic_family.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,9 @@ OpResult<void> OpRen(const OpArgs& op_args, string_view from_key, string_view to
870870
is_prior_list = (to_res.it->second.ObjType() == OBJ_LIST);
871871
}
872872

873+
// Delete the "from" document from the search index before deleting from the database
874+
op_args.shard->search_indices()->RemoveDoc(from_key, op_args.db_cntx, from_res.it->second);
875+
873876
bool sticky = from_res.it->first.IsSticky();
874877
uint64_t exp_ts = db_slice.ExpireTime(from_res.exp_it);
875878

src/server/search/search_family_test.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,4 +2722,23 @@ TEST_F(SearchFamilyTest, JsonWithNullFields) {
27222722
AreDocIds("doc:1", "doc:2"));
27232723
}
27242724

2725+
TEST_F(SearchFamilyTest, RenameDocumentBetweenIndices) {
2726+
absl::FlagSaver fs;
2727+
2728+
SetTestFlag("cluster_mode", "emulated");
2729+
ResetService();
2730+
2731+
EXPECT_EQ(Run({"ft.create", "idx1", "prefix", "1", "idx1", "filter", "@index==\"yes\"", "schema",
2732+
"t", "text"}),
2733+
"OK");
2734+
EXPECT_EQ(Run({"ft.create", "idx2", "prefix", "1", "idx2", "filter", "@index==\"yes\"", "schema",
2735+
"t", "text"}),
2736+
"OK");
2737+
2738+
Run({"hset", "idx1:{doc}1", "t", "foo1", "index", "yes"});
2739+
2740+
EXPECT_EQ(Run({"rename", "idx1:{doc}1", "idx2:{doc}1"}), "OK");
2741+
EXPECT_EQ(Run({"rename", "idx2:{doc}1", "idx1:{doc}1"}), "OK");
2742+
}
2743+
27252744
} // namespace dfly

0 commit comments

Comments
 (0)