Skip to content

Commit 8854117

Browse files
authored
[TEST] wait for all active shards when indexing data (#122163)
This attempts to fix a flay test where the term_freq returned by the multiple terms vectors API was `null`. I was not able to reproduce this test but this proposes a fix based on the following running theory: - an Elasticsearch cluster comprised of at least 2 nodes - we create a couple of indices with 1 primary and 1 replica - we index a document that was acknowledged only by the primary (because `wait_for_active_shards` defaults to `1`) - the test executes the multiple terms vectors API and it hits the node hosting the replica shard, which hasn't yet received the document we ingested in the primary shard. This race condition between the document replication and the test running the terms vectors API on the replica shard could yield a `null` value for the the term's `term_freq` (as the replica shard contains 0 documents). This PR proposes we change the `wait_for_active_shards` value to `all` so each write is acknowledged by all replicas before the client receives the response. (cherry picked from commit a148fa2) Signed-off-by: Andrei Dan <[email protected]>
1 parent 86542f0 commit 8854117

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ tests:
4646
- class: org.elasticsearch.packaging.test.WindowsServiceTests
4747
method: test81JavaOptsInJvmOptions
4848
issue: https://github.com/elastic/elasticsearch/issues/113313
49-
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
50-
method: test {p0=mtermvectors/10_basic/Tests catching other exceptions per item}
51-
issue: https://github.com/elastic/elasticsearch/issues/113325
5249
- class: org.elasticsearch.xpack.transform.integration.TransformIT
5350
method: testStopWaitForCheckpoint
5451
issue: https://github.com/elastic/elasticsearch/issues/106113

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/mtermvectors/10_basic.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ setup:
33
- do:
44
indices.create:
55
index: testidx
6+
wait_for_active_shards: all
67
body:
78
mappings:
89
properties:
@@ -80,6 +81,7 @@ setup:
8081
- do:
8182
indices.create:
8283
index: testidx2
84+
wait_for_active_shards: all
8385

8486
- do:
8587
indices.put_alias:

0 commit comments

Comments
 (0)