Fixing handling of auto slices in bulk scroll requests (#43050) (#43063)

* Fixing handling of auto slices in bulk scroll requests

* adjusting assertions for tests
This commit is contained in:
Benjamin Trent 2019-06-10 16:47:40 -05:00 committed by GitHub
parent 1ddc4c8fc6
commit 0a95b8c24d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 1 deletions

View File

@ -112,7 +112,7 @@ class BulkByScrollParallelizationHelper {
(sum, term) -> sum + term (sum, term) -> sum + term
)); ));
Set<Integer> counts = new HashSet<>(countsByIndex.values()); Set<Integer> counts = new HashSet<>(countsByIndex.values());
int leastShards = Collections.min(counts); int leastShards = counts.isEmpty() ? 1 : Collections.min(counts);
return Math.min(leastShards, AUTO_SLICE_CEILING); return Math.min(leastShards, AUTO_SLICE_CEILING);
} }

View File

@ -306,4 +306,13 @@ public class DeleteByQueryBasicTests extends ReindexTestCase {
} }
public void testMissingSources() {
BulkByScrollResponse response = updateByQuery()
.source("missing-index-*")
.refresh(true)
.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES)
.get();
assertThat(response, matcher().deleted(0).slices(hasSize(0)));
}
} }

View File

@ -157,5 +157,13 @@ public class ReindexBasicTests extends ReindexTestCase {
assertHitCount(client().prepareSearch("dest").setSize(0).get(), allDocs.size()); assertHitCount(client().prepareSearch("dest").setSize(0).get(), allDocs.size());
} }
public void testMissingSources() {
BulkByScrollResponse response = updateByQuery()
.source("missing-index-*")
.refresh(true)
.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES)
.get();
assertThat(response, matcher().created(0).slices(hasSize(0)));
}
} }

View File

@ -160,4 +160,13 @@ public class UpdateByQueryBasicTests extends ReindexTestCase {
assertEquals(2, client().prepareGet(index, "test", Integer.toString(randomDoc)).get().getVersion()); assertEquals(2, client().prepareGet(index, "test", Integer.toString(randomDoc)).get().getVersion());
} }
} }
public void testMissingSources() {
BulkByScrollResponse response = updateByQuery()
.source("missing-index-*")
.refresh(true)
.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES)
.get();
assertThat(response, matcher().updated(0).slices(hasSize(0)));
}
} }