Skip to content

Commit a90b6b6

Browse files
authored
Fix noop_update_total metric in indexing stats cannot be updated by bulk API (#11485)
Signed-off-by: Gao Binlong <gbinlong@amazon.com>
1 parent 6aab360 commit a90b6b6

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
216216
- Fix remote shards balancer and remove unused variables ([#11167](https://github.com/opensearch-project/OpenSearch/pull/11167))
217217
- Fix parsing of flat object fields with dots in keys ([#11425](https://github.com/opensearch-project/OpenSearch/pull/11425))
218218
- Fix bug where replication lag grows post primary relocation ([#11238](https://github.com/opensearch-project/OpenSearch/pull/11238))
219+
- Fix noop_update_total metric in indexing stats cannot be updated by bulk API ([#11485](https://github.com/opensearch-project/OpenSearch/pull/11485))
219220
- Fix for stuck update action in a bulk with `retry_on_conflict` property ([#11152](https://github.com/opensearch-project/OpenSearch/issues/11152))
220221
- Fix template setting override for replication type ([#11417](https://github.com/opensearch-project/OpenSearch/pull/11417))
221222
- Fix Automatic addition of protocol broken in #11512 ([#11609](https://github.com/opensearch-project/OpenSearch/pull/11609))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
setup:
3+
4+
- do:
5+
indices.create:
6+
index: test1
7+
wait_for_active_shards: all
8+
body:
9+
settings:
10+
index.number_of_shards: 1
11+
index.number_of_replicas: 1
12+
13+
- do:
14+
index:
15+
index: test1
16+
id: 1
17+
body: { "bar": "bar" }
18+
19+
- do:
20+
indices.refresh: {}
21+
22+
# Related issue: https://github.com/opensearch-project/OpenSearch/issues/9857
23+
---
24+
"Test noop_update_total metric can be updated by both update API and bulk API":
25+
- skip:
26+
version: " - 2.99.99" #TODO: change to 2.11.99 after the PR is backported to 2.x branch
27+
reason: "fixed in 3.0"
28+
29+
- do:
30+
update:
31+
index: test1
32+
id: 1
33+
body: { "doc": { "bar": "bar" } }
34+
35+
- do:
36+
indices.stats:
37+
index: test1
38+
metric: indexing
39+
40+
- match: { indices.test1.primaries.indexing.noop_update_total: 1 }
41+
- match: { indices.test1.total.indexing.noop_update_total: 1 }
42+
43+
- do:
44+
bulk:
45+
body: |
46+
{"update": {"_id": "1", "_index": "test1"}}
47+
{"doc": {"bar": "bar"}}
48+
49+
- do:
50+
indices.stats:
51+
index: test1
52+
metric: indexing
53+
54+
- match: { indices.test1.primaries.indexing.noop_update_total: 2 }
55+
- match: { indices.test1.total.indexing.noop_update_total: 2 }

server/src/internalClusterTest/java/org/opensearch/action/bulk/BulkWithUpdatesIT.java

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.opensearch.action.DocWriteRequest.OpType;
3636
import org.opensearch.action.DocWriteResponse;
3737
import org.opensearch.action.admin.indices.alias.Alias;
38+
import org.opensearch.action.admin.indices.stats.IndicesStatsRequest;
39+
import org.opensearch.action.admin.indices.stats.IndicesStatsResponse;
3840
import org.opensearch.action.delete.DeleteRequest;
3941
import org.opensearch.action.get.GetResponse;
4042
import org.opensearch.action.index.IndexRequest;
@@ -738,6 +740,12 @@ public void testNoopUpdate() {
738740
equalTo(2)
739741
);
740742

743+
// test noop_update_total metric in stats changed
744+
IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest().indices(indexName).indexing(true);
745+
final IndicesStatsResponse indicesStatsResponse = client().admin().indices().stats(indicesStatsRequest).actionGet();
746+
assertThat(indicesStatsResponse.getIndex(indexName).getTotal().indexing.getTotal().getNoopUpdateCount(), equalTo(1L));
747+
assertThat(indicesStatsResponse.getIndex(indexName).getPrimaries().indexing.getTotal().getNoopUpdateCount(), equalTo(1L));
748+
741749
final BulkItemResponse notFoundUpdate = bulkResponse.getItems()[1];
742750
assertNotNull(notFoundUpdate.getFailure());
743751

server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java

+1
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ static boolean executeBulkItemRequest(
593593
context.setRequestToExecute(updateResult.action());
594594
break;
595595
case NOOP:
596+
context.getPrimary().noopUpdate();
596597
context.markOperationAsNoOp(updateResult.action());
597598
context.markAsCompleted(context.getExecutionResult());
598599
return true;

0 commit comments

Comments
 (0)