{"record":{"id":"876a577f3b85f148","repo":"apache/pulsar","slug":"the-load-shedding-strategy-loadbalancerloadshed","errorCode":null,"errorMessage":"The load shedding strategy: ${loadBalancerLoadSheddingStrategy} can't work with the placement strategy: ${loadBalancerLoadPlacementStrategy}","messagePattern":"The load shedding strategy: (.+?) can't work with the placement strategy: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java","lineNumber":273,"sourceCode":"        sheddingExcludedNamespaceSelectionStrategy = new RoundRobinBrokerSelector();\n        policies = new SimpleResourceAllocationPolicies(pulsar);\n        filterPipeline.add(new BrokerLoadManagerClassFilter());\n        filterPipeline.add(new BrokerVersionFilter());\n\n        LoadManagerShared.refreshBrokerToFailureDomainMap(pulsar, brokerToFailureDomainMap);\n        // register listeners for domain changes\n        pulsarResources.getClusterResources().getFailureDomainResources()\n                .registerListener(__ -> {\n                    executors.execute(\n                            () -> LoadManagerShared.refreshBrokerToFailureDomainMap(pulsar, brokerToFailureDomainMap));\n                });\n\n        if (placementStrategy instanceof LoadSheddingStrategy) {\n            // if the placement strategy is also a load shedding strategy\n            // we need to check two strategies are the same\n            if (!conf.getLoadBalancerLoadSheddingStrategy().equals(\n                    conf.getLoadBalancerLoadPlacementStrategy())) {\n                throw new IllegalArgumentException(\"The load shedding strategy: \"\n                        + conf.getLoadBalancerLoadSheddingStrategy()\n                        + \" can't work with the placement strategy: \"\n                        + conf.getLoadBalancerLoadPlacementStrategy());\n            }\n            // bind the load shedding strategy and the placement strategy\n            loadSheddingStrategy = (LoadSheddingStrategy) placementStrategy;\n        } else {\n            loadSheddingStrategy = createLoadSheddingStrategy();\n        }\n    }\n\n    public void handleDataNotification(Notification t) {\n        if (t.getPath().startsWith(LoadManager.LOADBALANCE_BROKERS_ROOT)) {\n            brokersData.listLocks(LoadManager.LOADBALANCE_BROKERS_ROOT)\n                    .thenAccept(brokers -> {\n                        reapDeadBrokerPreallocations(brokers);\n                    });\n","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java#L255-L291","documentation":"ModularLoadManagerImpl.initialize instantiates the configured placement strategy; if that class also implements LoadSheddingStrategy, the same instance is used for both placement and shedding, which is only allowed when loadBalancerLoadSheddingStrategy and loadBalancerLoadPlacementStrategy name the same class. Otherwise initialize throws IllegalArgumentException at broker startup.","triggerScenarios":"Broker starts with loadBalancerLoadPlacementStrategy set to a class that implements LoadSheddingStrategy while loadBalancerLoadSheddingStrategy names a different class (default placement is NOT a shedding strategy, so this needs deliberate config).","commonSituations":"Operators copy configs between clusters and change only one of the two properties; custom placement strategies that implement both interfaces; typos where one property got a shedding class and the other kept the default.","solutions":["Make both properties reference the same strategy class, e.g. set loadBalancerLoadSheddingStrategy and loadBalancerLoadPlacementStrategy to the same FQN.","Or revert loadBalancerLoadPlacementStrategy to a pure placement strategy that does not implement LoadSheddingStrategy (e.g. the default).","Remove the custom combined strategy and use the standard shedding/placement pair.","Validate the two config values together in deployment tooling before rollout."],"exampleFix":"# before\nloadBalancerLoadPlacementStrategy=org.apache.pulsar.broker.loadbalance.impl.MinimizeMemoryPlacementStrategyThatAlsoSheds\nloadBalancerLoadSheddingStrategy=org.apache.pulsar.broker.loadbalance.impl.ThresholdShedder\n# after (same class for both, or a pure placement strategy)\nloadBalancerLoadPlacementStrategy=org.apache.pulsar.broker.loadbalance.impl.MinimizeMemoryPlacementStrategyThatAlsoSheds\nloadBalancerLoadSheddingStrategy=org.apache.pulsar.broker.loadbalance.impl.MinimizeMemoryPlacementStrategyThatAlsoSheds","handlingStrategy":"validation","validationCode":"Class<?> placement = Class.forName(conf.getLoadBalancerLoadPlacementStrategy());\nif (LoadSheddingStrategy.class.isAssignableFrom(placement)\n    && !conf.getLoadBalancerLoadSheddingStrategy()\n        .equals(conf.getLoadBalancerLoadPlacementStrategy())) {\n    throw new IllegalArgumentException(\"Shedding and placement strategies must match when placement sheds\");\n}","typeGuard":"boolean isCombinedStrategy(String placementClass) {\n    try { return LoadSheddingStrategy.class.isAssignableFrom(Class.forName(placementClass)); }\n    catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n    new ModularLoadManagerImpl(pulsar, coordinator, checkOwnershipRequired);\n} catch (IllegalArgumentException e) {\n    log.error(\"Load manager config invalid: {}\", e.getMessage());\n    // fail startup clearly instead of masking the config mistake\n}","preventionTips":["When placement strategy implements LoadSheddingStrategy, always set both config keys to the identical FQN.","Diff both properties together when copying configs between clusters.","Smoke-test broker startup with production service configuration before rollout."],"tags":["configuration","load-manager","load-shedding","broker-startup"],"backgroundTag":"incompatible-strategy-configuration","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}