Skip to content

Commit

Permalink
Update error message when lucene max document limit is breached (open…
Browse files Browse the repository at this point in the history
…search-project#11312)

* Update error message when lucene document limit is breached

Signed-off-by: Shreyansh Ray <[email protected]>

* Update error message as per review comments

Signed-off-by: Shreyansh Ray <[email protected]>

---------

Signed-off-by: Shreyansh Ray <[email protected]>
  • Loading branch information
rayshrey authored Nov 28, 2023
1 parent 2898f13 commit 25cb920
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,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

0 comments on commit 25cb920

Please sign in to comment.