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

Update error message when lucene max document limit is breached #11312

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Disable concurrent aggs for Diversified Sampler and Sampler aggs ([#11087](https://github.com/opensearch-project/OpenSearch/issues/11087))
- Made leader/follower check timeout setting dynamic ([#10528](https://github.com/opensearch-project/OpenSearch/pull/10528))
- Improve boolean parsing performance ([#11308](https://github.com/opensearch-project/OpenSearch/pull/11308))
- Change error message when per shard document limit is breached ([#11312](https://github.com/opensearch-project/OpenSearch/pull/11312))

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.opensearch.action.search.SearchResponse;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.index.Index;
import org.opensearch.core.index.shard.ShardId;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.MediaTypeRegistry;
import org.opensearch.index.IndexSettings;
Expand Down Expand Up @@ -65,6 +67,7 @@
public class MaxDocsLimitIT extends OpenSearchIntegTestCase {

private static final AtomicInteger maxDocs = new AtomicInteger();
private static final ShardId shardId = new ShardId(new Index("test", "_na_"), 0);

public static class TestEnginePlugin extends Plugin implements EnginePlugin {
@Override
Expand Down Expand Up @@ -122,7 +125,10 @@ public void testMaxDocsLimit() throws Exception {
IllegalArgumentException.class,
() -> client().prepareDelete("test", "any-id").get()
);
assertThat(deleteError.getMessage(), containsString("Number of documents in the index can't exceed [" + maxDocs.get() + "]"));
assertThat(
deleteError.getMessage(),
containsString("Number of documents in shard " + shardId + " exceeds the limit of [" + maxDocs.get() + "] documents per shard")
);
client().admin().indices().prepareRefresh("test").get();
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(new MatchAllQueryBuilder())
Expand Down Expand Up @@ -208,7 +214,16 @@ static IndexingResult indexDocs(int numRequests, int numThreads) throws Exceptio
assertThat(resp.status(), equalTo(RestStatus.CREATED));
} catch (IllegalArgumentException e) {
numFailure.incrementAndGet();
assertThat(e.getMessage(), containsString("Number of documents in the index can't exceed [" + maxDocs.get() + "]"));
assertThat(
e.getMessage(),
containsString(
"Number of documents in shard "
+ shardId
+ " exceeds the limit of ["
+ maxDocs.get()
+ "] documents per shard"
)
);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,9 @@ private Exception tryAcquireInFlightDocs(Operation operation, int addingDocs) {
final long totalDocs = indexWriter.getPendingNumDocs() + inFlightDocCount.addAndGet(addingDocs);
if (totalDocs > maxDocs) {
releaseInFlightDocs(addingDocs);
return new IllegalArgumentException("Number of documents in the index can't exceed [" + maxDocs + "]");
return new IllegalArgumentException(
"Number of documents in shard " + shardId + " exceeds the limit of [" + maxDocs + "] documents per shard"
);
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7801,7 +7801,9 @@ public void testMaxDocsOnPrimary() throws Exception {
assertNotNull(result.getFailure());
assertThat(
result.getFailure().getMessage(),
containsString("Number of documents in the index can't exceed [" + maxDocs + "]")
containsString(
"Number of documents in shard " + shardId + " exceeds the limit of [" + maxDocs + "] documents per shard"
)
);
assertThat(result.getSeqNo(), equalTo(UNASSIGNED_SEQ_NO));
assertThat(engine.getLocalCheckpointTracker().getMaxSeqNo(), equalTo(maxSeqNo));
Expand Down
Loading