Skip to content

Commit 9daa870

Browse files
authored
KnnIndexer: update index count to not appear as if it has indexed more than more docs than it has (#132577)
Currently each index thread updates the number of docs indexed before checking the configured number of docs to index, but can lead to an impression that more docs have been indexed than requested. The solution is to only update when there is head room.
1 parent 569121b commit 9daa870

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

qa/vector/src/main/java/org/elasticsearch/test/knn/KnnIndexer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,11 @@ public void run() {
270270

271271
private void _run() throws IOException {
272272
while (true) {
273-
int id = numDocsIndexed.getAndIncrement();
274-
if (id >= numDocsToIndex) {
273+
int id = numDocsIndexed.get();
274+
if (id == numDocsToIndex) {
275275
break;
276+
} else if (numDocsIndexed.compareAndSet(id, id + 1) == false) {
277+
continue;
276278
}
277279

278280
Document doc = new Document();

0 commit comments

Comments
 (0)