Skip to content

Commit

Permalink
Fix noop_update_total metric in indexing stats cannot be updated by b…
Browse files Browse the repository at this point in the history
…ulk API (opensearch-project#11485)

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
  • Loading branch information
gaobinlong authored and shiv0408 committed Apr 25, 2024
1 parent 3c1f4c3 commit f2f61ff
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix remote shards balancer and remove unused variables ([#11167](https://github.com/opensearch-project/OpenSearch/pull/11167))
- Fix parsing of flat object fields with dots in keys ([#11425](https://github.com/opensearch-project/OpenSearch/pull/11425))
- Fix bug where replication lag grows post primary relocation ([#11238](https://github.com/opensearch-project/OpenSearch/pull/11238))
- Fix noop_update_total metric in indexing stats cannot be updated by bulk API ([#11485](https://github.com/opensearch-project/OpenSearch/pull/11485))
- Fix for stuck update action in a bulk with `retry_on_conflict` property ([#11152](https://github.com/opensearch-project/OpenSearch/issues/11152))
- Fix template setting override for replication type ([#11417](https://github.com/opensearch-project/OpenSearch/pull/11417))
- Fix Automatic addition of protocol broken in #11512 ([#11609](https://github.com/opensearch-project/OpenSearch/pull/11609))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
setup:

- do:
indices.create:
index: test1
wait_for_active_shards: all
body:
settings:
index.number_of_shards: 1
index.number_of_replicas: 1

- do:
index:
index: test1
id: 1
body: { "bar": "bar" }

- do:
indices.refresh: {}

# Related issue: https://github.com/opensearch-project/OpenSearch/issues/9857
---
"Test noop_update_total metric can be updated by both update API and bulk API":
- skip:
version: " - 2.99.99" #TODO: change to 2.11.99 after the PR is backported to 2.x branch
reason: "fixed in 3.0"

- do:
update:
index: test1
id: 1
body: { "doc": { "bar": "bar" } }

- do:
indices.stats:
index: test1
metric: indexing

- match: { indices.test1.primaries.indexing.noop_update_total: 1 }
- match: { indices.test1.total.indexing.noop_update_total: 1 }

- do:
bulk:
body: |
{"update": {"_id": "1", "_index": "test1"}}
{"doc": {"bar": "bar"}}
- do:
indices.stats:
index: test1
metric: indexing

- match: { indices.test1.primaries.indexing.noop_update_total: 2 }
- match: { indices.test1.total.indexing.noop_update_total: 2 }
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.opensearch.action.DocWriteRequest.OpType;
import org.opensearch.action.DocWriteResponse;
import org.opensearch.action.admin.indices.alias.Alias;
import org.opensearch.action.admin.indices.stats.IndicesStatsRequest;
import org.opensearch.action.admin.indices.stats.IndicesStatsResponse;
import org.opensearch.action.delete.DeleteRequest;
import org.opensearch.action.get.GetResponse;
import org.opensearch.action.index.IndexRequest;
Expand Down Expand Up @@ -738,6 +740,12 @@ public void testNoopUpdate() {
equalTo(2)
);

// test noop_update_total metric in stats changed
IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest().indices(indexName).indexing(true);
final IndicesStatsResponse indicesStatsResponse = client().admin().indices().stats(indicesStatsRequest).actionGet();
assertThat(indicesStatsResponse.getIndex(indexName).getTotal().indexing.getTotal().getNoopUpdateCount(), equalTo(1L));
assertThat(indicesStatsResponse.getIndex(indexName).getPrimaries().indexing.getTotal().getNoopUpdateCount(), equalTo(1L));

final BulkItemResponse notFoundUpdate = bulkResponse.getItems()[1];
assertNotNull(notFoundUpdate.getFailure());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ static boolean executeBulkItemRequest(
context.setRequestToExecute(updateResult.action());
break;
case NOOP:
context.getPrimary().noopUpdate();
context.markOperationAsNoOp(updateResult.action());
context.markAsCompleted(context.getExecutionResult());
return true;
Expand Down

0 comments on commit f2f61ff

Please sign in to comment.