apache / helix

Mirror of Apache Helix
Apache License 2.0
457 stars 218 forks source link

partitionAssignment fails for resources with ANY_LIVEINSTANCE replica count #2816

Closed GrantPSpencer closed 1 week ago

GrantPSpencer commented 1 month ago

Describe the bug

partitionAssignment fails to calculate when there is FULL_AUTO resource that has ANY_LIVEINSTANCE for replica count.

To Reproduce

Create a resource that utilizes ANY_LIVEINSTANCE, then call partitionAssignment on the cluster and it will fail to compute. Stack trace will show it failed due to a java.lang.NumberFormatException. This is due to Integer.parseInt(idealState.getReplicas()) in the getIdealAssignmentForFullAuto method. idealState.getReplicas returns "ANY_LIVEINSTANCE" which then fails to be parsed to an int.

Full stack trace here:

"message": Failed to compute partition assignment,
"exceptionChain": [
    {
        "index": 0,
        "message": "For input string: \"ANY_LIVEINSTANCE\"",
        "stackTrace": [
            {
                "index": 0,
                "call": "forInputString",
                "columnNumber": null,
                "fileName": "NumberFormatException.java",
                "lineNumber": 65,
                "nativeMethod": "0",
                "source": "java.lang.NumberFormatException"
            },
            {
                "index": 1,
                "call": "parseInt",
                "columnNumber": null,
                "fileName": "Integer.java",
                "lineNumber": 652,
                "nativeMethod": "0",
                "source": "java.lang.Integer"
            },
            {
                "index": 2,
                "call": "parseInt",
                "columnNumber": null,
                "fileName": "Integer.java",
                "lineNumber": 770,
                "nativeMethod": "0",
                "source": "java.lang.Integer"
            },
            {
                "index": 3,
                "call": "getIdealAssignmentForFullAuto",
                "columnNumber": null,
                "fileName": "HelixUtil.java",
                "lineNumber": 397,
                "nativeMethod": "0",
                "source": "org.apache.helix.util.HelixUtil"
            },
            {
                "index": 4,
                "call": "computeOptimalAssignmentForResources",
                "columnNumber": null,
                "fileName": "ResourceAssignmentOptimizerAccessor.java",
                "lineNumber": 284,
                "nativeMethod": "0",
                "source": "org.apache.helix.rest.server.resources.helix.ResourceAssignmentOptimizerAccessor"
            },
            {
                "index": 5,
                "call": "computePotentialAssignment",
                "columnNumber": null,
                "fileName": "ResourceAssignmentOptimizerAccessor.java",
                "lineNumber": 146,
                "nativeMethod": "0",
                "source": "org.apache.helix.rest.server.resources.helix.ResourceAssignmentOptimizerAccessor"
            },

Expected behavior

partitionAssignment should treat ANY_LIVEINSTANCE similar to the controller or should explicitly exclude these resources from calculation.