@@ -2768,6 +2768,47 @@ TEST_F(SearchFamilyTest, JsonSetIndexesBug) {
2768
2768
EXPECT_THAT (resp, IsUnordArrayWithSize (IsMap (" text" , " some text" )));
2769
2769
}
2770
2770
2771
+ TEST_F (SearchFamilyTest, SearchReindexWriteSearchRace) {
2772
+ const std::string kIndexName = " myRaceIdx" ;
2773
+ const int kWriterOps = 200 ;
2774
+ const int kSearcherOps = 200 ;
2775
+ const int kReindexerOps = 200 ;
2776
+
2777
+ auto writer_fiber = pp_->at (0 )->LaunchFiber ([&] {
2778
+ for (int i = 1 ; i <= kWriterOps ; ++i) {
2779
+ std::string doc_key = absl::StrCat (" doc:" , i);
2780
+ std::string content = absl::StrCat (" text data item " , i, " for race condition test" );
2781
+ std::string tags_val = absl::StrCat (" tagA,tagB," , (i % 10 ));
2782
+ std::string numeric_field_val = std::to_string (i);
2783
+ Run ({" hset" , doc_key, " content" , content, " tags" , tags_val, " numeric_field" ,
2784
+ numeric_field_val});
2785
+ }
2786
+ });
2787
+
2788
+ auto searcher_fiber = pp_->at (1 )->LaunchFiber ([&] {
2789
+ for (int i = 1 ; i <= kSearcherOps ; ++i) {
2790
+ int random_val_content = 1 + (i % kWriterOps );
2791
+ std::string query_content = absl::StrCat (" @content:item" , random_val_content);
2792
+ Run ({" ft.search" , kIndexName , query_content});
2793
+ }
2794
+ });
2795
+
2796
+ auto reindexer_fiber = pp_->at (2 )->LaunchFiber ([&] {
2797
+ for (int i = 1 ; i <= kReindexerOps ; ++i) {
2798
+ Run ({" ft.create" , kIndexName , " ON" , " HASH" , " PREFIX" , " 1" , " doc:" , " SCHEMA" , " content" ,
2799
+ " TEXT" , " SORTABLE" , " tags" , " TAG" , " SORTABLE" , " numeric_field" , " NUMERIC" , " SORTABLE" });
2800
+ Run ({" ft.dropindex" , kIndexName });
2801
+ }
2802
+ });
2803
+
2804
+ // Join fibers
2805
+ writer_fiber.Join ();
2806
+ searcher_fiber.Join ();
2807
+ reindexer_fiber.Join ();
2808
+
2809
+ ASSERT_FALSE (service_->IsShardSetLocked ());
2810
+ }
2811
+
2771
2812
TEST_F (SearchFamilyTest, IgnoredOptionsInFtCreate) {
2772
2813
Run ({" HSET" , " doc:1" , " title" , " Test Document" });
2773
2814
0 commit comments