Skip to content

Commit 90e4c4d

Browse files
gtwang01facebook-github-bot
authored andcommitted
Fix SCD Table test flakiness (facebookresearch#4069)
Summary: Pull Request resolved: facebookresearch#4069 Test often fails due to bad file descriptor: https://www.internalfb.com/intern/testinfra/diagnostics/12384899035372280.281475109760157.1733399744/ This is due to the filename in the test being the same across all runs - when there are multiple concurrent runs, there will be problems accessing the file. The solution is to add a randomized component to the temp file, similar to other tests like ```test_io_with_options```, which prevents concurrent accesses of a file. Reviewed By: pankajsingh88 Differential Revision: D66846937 fbshipit-source-id: d1d3c9ce817c4ce06283db265f13fe1413c2a14b
1 parent 750381d commit 90e4c4d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/test_disable_pq_sdc_tables.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@
1818
pthread_mutex_t temp_file_mutex = PTHREAD_MUTEX_INITIALIZER;
1919

2020
TEST(IO, TestReadHNSWPQ_whenSDCDisabledFlagPassed_thenDisableSDCTable) {
21-
Tempfilename index_filename(&temp_file_mutex, "/tmp/faiss_TestReadHNSWPQ");
21+
// Create a temp file name with a randomized component for stress runs
22+
std::random_device rd;
23+
std::mt19937 mt(rd());
24+
std::uniform_real_distribution<float> dist(0, 9999999);
25+
std::string temp_file_name =
26+
"/tmp/faiss_TestReadHNSWPQ" + std::to_string(int(dist(mt)));
27+
Tempfilename index_filename(&temp_file_mutex, temp_file_name);
28+
29+
// Create a HNSW index with PQ encoding
2230
int d = 32, n = 256;
2331
std::default_random_engine rng(123);
2432
std::uniform_real_distribution<float> u(0, 100);

0 commit comments

Comments
 (0)