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] Deserialization bug in weighted round robin metadata #11697

Closed
anshu1106 opened this issue Jan 2, 2024 · 0 comments · Fixed by #11679
Closed

[BUG] Deserialization bug in weighted round robin metadata #11697

anshu1106 opened this issue Jan 2, 2024 · 0 comments · Fixed by #11679
Labels
bug Something isn't working Search Search query, autocomplete ...etc

Comments

@anshu1106
Copy link
Contributor

anshu1106 commented Jan 2, 2024

Describe the bug

When weighted round robin weights is deleted for a domain, the weighted routing metadata is set to empty in the cluster state.

Weighted Routing Metadata with weights

"weighted_shard_routing": {
            "awareness": {
                "zone": {
                    "ap-southeast-2b": 1,
                    "ap-southeast-2a": 0,
                    "ap-southeast-2c": 1
                }
            },
            "_version": 2
        }

Weighted Routing Metadata after weights deletion

 "weighted_shard_routing": { "awareness": {}, "_version": 3 }

Due to a bug in deserialization where attributeName is set to null if not present, a NPE is seen.

Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "str" is null
        at org.opensearch.core.common.io.stream.StreamOutput.writeString(StreamOutput.java:443)
        at org.opensearch.cluster.routing.WeightedRouting.writeTo(WeightedRouting.java:55)
        at org.opensearch.cluster.metadata.WeightedRoutingMetadata.writeTo(WeightedRoutingMetadata.java:91)
        at org.opensearch.core.common.io.stream.StreamOutput.writeNamedWriteable(StreamOutput.java:1126)
        at org.opensearch.cluster.metadata.Metadata.writeTo(Metadata.java:1145)
        at org.opensearch.cluster.ClusterState.writeTo(ClusterState.java:783)
        at org.opensearch.cluster.coordination.PublicationTransportHandler.lambda$serializeFullClusterState$2(PublicationTransportHandler.java:240)
        at org.opensearch.cluster.coordination.CompressedStreamUtils.createCompressedStream(CompressedStreamUtils.java:42)
        at org.opensearch.cluster.coordination.PublicationTransportHandler.serializeFullClusterState(PublicationTransportHandler.java:238)
        at org.opensearch.cluster.coordination.PublicationTransportHandler$PublicationContext.buildDiffAndSerializeStates(PublicationTransportHandler.java:287)
        at org.opensearch.cluster.coordination.PublicationTransportHandler.newPublicationContext(PublicationTransportHandler.java:233)
        at org.opensearch.cluster.coordination.Coordinator.publish(Coordinator.java:1312)

Related component

Search

To Reproduce

  1. Create a 1 or 2 node domain and add weighted round robin weights.
  2. Delete weights
  3. kill the active master OS process
  4. 'ClusterManagerNotDiscovered` exception is seen.
  5. Restart OS process
  6. NPE is seen in OpenSearch logs

Expected behavior

After removal of weights there should not be any failure in the code

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Search Search query, autocomplete ...etc
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant