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 (#11485)

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Jan 11, 2024
1 parent 6aab360 commit a90b6b6
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 a90b6b6

Please sign in to comment.