HDDS-15350. SCM crashes with ArithmeticException when topology reports zero racks during DN decommission#10339
Draft
smengcl wants to merge 1 commit into
Draft
HDDS-15350. SCM crashes with ArithmeticException when topology reports zero racks during DN decommission#10339smengcl wants to merge 1 commit into
smengcl wants to merge 1 commit into
Conversation
…s zero racks during DN decommission
SCMCommonPlacementPolicy.getMaxReplicasPerRack divides by numberOfRacks
without a zero check. The caller (validateContainerPlacement) reaches the
divide via Math.min(requiredRacks, numRacks); when the network topology
transiently reports zero racks (observed during a DN decommission) the
existing requiredRacks==1 short-circuit does not catch it. The
ReplicationMonitor catches the exception and calls ExitUtil.terminate(1, t)
("When we get runtime exception, we should terminate SCM."), so the SCM
JVM exits and is restarted by the supervisor (CM / systemd).
Fix:
* Compute numRacks before the early-return guard and short-circuit when
numRacks <= 0 or requiredRacks <= 1 (was: == 1).
* Add a defensive guard in getMaxReplicasPerRack that returns numReplicas
when numberOfRacks <= 0, mirroring HDDS-14371's pattern for an
analogous div-by-zero in ContainerManagerImpl.
Test:
* TestSCMCommonPlacementPolicy.testValidateContainerPlacementWithZeroRackTopology
reproduces the empty-topology window with a mocked NetworkTopology
returning 0 from getNumOfNodes. Without the fix the test errors out
with "Arithmetic / by zero". With the fix it passes and all 20 tests
in TestSCMCommonPlacementPolicy remain green.
Generated-by: Claude Code (Opus 4.7)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated-by: Claude Code (Opus 4.7)
What changes were proposed in this pull request?
SCMCommonPlacementPolicy.getMaxReplicasPerRack divides by numberOfRacks without a zero check. The caller (
validateContainerPlacement) reaches the divide viaMath.min(requiredRacks, numRacks).When the network topology transiently reports zero racks (observed during a DN decommission) the existing
requiredRacks==1short-circuit does not catch it. TheReplicationMonitorcatches the exception and calls:so the SCM JVM exits.
Fix:
numRacks <= 0orrequiredRacks <= 1(was: == 1).numberOfRacks <= 0, mirroring HDDS-14371's pattern for an analogous div-by-zero inContainerManagerImpl.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15350
How was this patch tested?
TestSCMCommonPlacementPolicy.testValidateContainerPlacementWithZeroRackTopologythat reproduces the empty-topology window with a mocked NetworkTopology returning 0 from getNumOfNodes. Without the fix the test errors out with "Arithmetic / by zero". With the fix it passes and all 20 tests in TestSCMCommonPlacementPolicy remain green.