Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix noop_update_total metric in indexing stats cannot be updated by bulk API #11485

Merged
merged 11 commits into from
Jan 11, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Remove shadowJar from `lang-painless` module publication ([#11369](https://github.com/opensearch-project/OpenSearch/issues/11369))
- Fix remote shards balancer and remove unused variables ([#11167](https://github.com/opensearch-project/OpenSearch/pull/11167))
- 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 template setting override for replication type ([#11417](https://github.com/opensearch-project/OpenSearch/pull/11417))

### Security
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
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();
gaobinlong marked this conversation as resolved.
Show resolved Hide resolved
context.markOperationAsNoOp(updateResult.action());
context.markAsCompleted(context.getExecutionResult());
return true;
Expand Down
Loading