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

[BUG] <title>NPE when SETTING_NUMBER_OF_REPLICAS is null #14783

Closed
jaytiBansal opened this issue Jul 17, 2024 · 5 comments · Fixed by #14812
Closed

[BUG] <title>NPE when SETTING_NUMBER_OF_REPLICAS is null #14783

jaytiBansal opened this issue Jul 17, 2024 · 5 comments · Fixed by #14812
Assignees
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing

Comments

@jaytiBansal
Copy link

Describe the bug

in OS 2.15, IndexSetting.java, method getNumberOfReplicas will give null pointer exception in scenarios when null is returned from settings.getAsInt methods because the return type of this method is int (not Integer).

public int getNumberOfReplicas() {
return settings.getAsInt(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, null);
}

Related component

Indexing

To Reproduce

Create an index with replica count passed as null.

Expected behavior

It should treat the default value as 1 for replica count is not passed.

Additional Details

[2024-07-16T17:02:27,740][DEBUG][o.o.c.m.MetadataCreateIndexService] [local_10-10] [ds7_dfs_] failed to create
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "org.opensearch.common.settings.Settings.getAsInt(String, java.lang.Integer)" is null
at org.opensearch.index.IndexSettings.getNumberOfReplicas(IndexSettings.java:1248)
at org.opensearch.indices.IndicesService.createIndexService(IndicesService.java:867)
at org.opensearch.indices.IndicesService.withTempIndexService(IndicesService.java:830)
at org.opensearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexWithTemporaryService(MetadataCreateIndexService.java:502)
at org.opensearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequestWithV1Templates(MetadataCreateIndexService.java:643)
at org.opensearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequest(MetadataCreateIndexService.java:464) ~
at org.opensearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequest(MetadataCreateIndexService.java:471)
at org.opensearch.cluster.metadata.MetadataCreateIndexService$1.execute(MetadataCreateIndexService.java:377)
at org.opensearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:67)
at org.opensearch.cluster.service.MasterService.executeTasks(MasterService.java:904)
at org.opensearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:456)
at org.opensearch.cluster.service.MasterService.runTasks(MasterService.java:316)
at org.opensearch.cluster.service.MasterService$Batcher.run(MasterService.java:227)
at org.opensearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:204)
at org.opensearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:242)
at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:882)
at org.opensearch.common.util.concurrent.PrioritizedOpenSearchThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedOpenSearchThreadPoolExecutor.java:283)

@jaytiBansal jaytiBansal added bug Something isn't working untriaged labels Jul 17, 2024
@github-actions github-actions bot added the Indexing Indexing, Bulk Indexing and anything related to indexing label Jul 17, 2024
@chishui
Copy link
Contributor

chishui commented Jul 18, 2024

The default value of replica count is not always 1, user can configure the default value through this cluster setting cluster.default_number_of_replicas, so simply changing default value from null to 1 won't work for every scenario.

I think it's better to treat index.number_of_replicas = null the same way as when index.number_of_replicas is missing from the payload.

@chishui
Copy link
Contributor

chishui commented Jul 18, 2024

Fixed in #14812

@mgodwan
Copy link
Member

mgodwan commented Jul 22, 2024

[Indexing Triage Meeting 07/22]

@chishui Thanks for working on this. I've assigned the issue to you. Please let us know if you are planning to continue working on it, and targeting to merge it within a release window.

@chishui
Copy link
Contributor

chishui commented Jul 23, 2024

@mgodwan I'm working on the PR #14812 and waiting for this to be approve and merged

@sandeshkr419
Copy link
Contributor

sandeshkr419 commented Aug 9, 2024

Complimenting my comment on #14810, if we have an agreement that null should be treated as 0 - then the same should apply here to keep consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants