Skip to content

Commit d657dfb

Browse files
pankajsingh88facebook-github-bot
authored andcommitted
fix merge_flat_ondisk stress run failures (#3999)
Summary: Pull Request resolved: #3999 Fixed the bug causing `merge_flat_ondisk` stress run failures. Running multiple `merge_flat_ondisk` tests simultaneously fails which is causing buck stress-run failures. https://www.internalfb.com/intern/test/562950025349567/ Root cause: we were updating input copy (which was discarded) of the filename template instead of the local copy. Reviewed By: asadoughi Differential Revision: D65074463 fbshipit-source-id: 9f86deeb56975a3be7a15a8f56d602463cad61af
1 parent 5539039 commit d657dfb

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

tests/test_merge.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct CommonData {
6060
};
6161

6262
CommonData cd;
63-
63+
std::string temp_filename_template = "/tmp/faiss_tmp_XXXXXX";
6464
/// perform a search on shards, then merge and search again and
6565
/// compare results.
6666
int compare_merged(
@@ -71,7 +71,7 @@ int compare_merged(
7171
std::vector<float> refD(k * nq);
7272

7373
index_shards->search(nq, cd.queries.data(), k, refD.data(), refI.data());
74-
Tempfilename filename(&temp_file_mutex, "/tmp/faiss_tmp_XXXXXX");
74+
Tempfilename filename(&temp_file_mutex, temp_filename_template);
7575

7676
std::vector<idx_t> newI(k * nq);
7777
std::vector<float> newD(k * nq);
@@ -191,7 +191,7 @@ TEST(MERGE, merge_flat_vt) {
191191
TEST(MERGE, merge_flat_ondisk) {
192192
faiss::IndexShards index_shards(d, false, false);
193193
index_shards.own_indices = true;
194-
Tempfilename filename(&temp_file_mutex, "/tmp/faiss_tmp_XXXXXX");
194+
Tempfilename filename(&temp_file_mutex, temp_filename_template);
195195

196196
for (int i = 0; i < nindex; i++) {
197197
auto ivf = new faiss::IndexIVFFlat(&cd.quantizer, d, nlist);

tests/test_util.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010

1111
#include <faiss/IndexIVFPQ.h>
1212
#include <unistd.h>
13-
#include <cstdlib>
1413

1514
struct Tempfilename {
1615
pthread_mutex_t* mutex;
1716
std::string filename;
1817

19-
Tempfilename(pthread_mutex_t* mutex, std::string filename) {
18+
Tempfilename(pthread_mutex_t* mutex, std::string filename_template) {
2019
this->mutex = mutex;
21-
this->filename = filename;
20+
this->filename = filename_template;
2221
pthread_mutex_lock(mutex);
23-
int fd = mkstemp(&filename[0]);
22+
int fd = mkstemp(&this->filename[0]);
2423
close(fd);
2524
pthread_mutex_unlock(mutex);
2625
}

0 commit comments

Comments
 (0)