[
https://issues.apache.org/jira/browse/IGNITE-29350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152881#comment-18152881
]
Alexey Gidaspov commented on IGNITE-29350:
------------------------------------------
(/) *No blockers* — [Ignite PR
Checker|https://ignite-pr-checker.is-a.dev/ignite?pr=13885] verdict for PR 13885
_RunAll [9533736|https://ci2.ignite.apache.org/build/9533736] ·
[26b4163|https://github.com/apache/ignite/pull/13885/commits/26b41632f39eef480e2d80f6406bfced7f8bd965]
·
[glossary|https://github.com/anton-vinogradov/ignite-pr-checker/blob/main/docs/features.md#verdict-glossary]_
Posted by ci2 user agidaspov from the checker's page.
> ArithmeticException: / by zero in affinity calculation when a dynamic cache
> group start coincides with a node join exchange merge
> ---------------------------------------------------------------------------------------------------------------------------------
>
> Key: IGNITE-29350
> URL: https://issues.apache.org/jira/browse/IGNITE-29350
> Project: Ignite
> Issue Type: Task
> Reporter: Alexey Gidaspov
> Assignee: Alexey Gidaspov
> Priority: Major
> Labels: ise
> Attachments: DynamicCacheOnNodeJoinTest.java
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> When a dynamic cache group is started while a server node join exchange is
> still in progress, the coordinator may recalculate affinity for that group
> using an outdated discovery
> snapshot.
>
>
>
>
>
> Under the following conditions:
>
>
>
>
>
> • the cache group is already present in the affinity registry;
>
>
> • a non-empty prevAssignment or baseline assignment exists;
>
>
> • the discovery snapshot for the current exchange contains no affinity
> nodes for the group;
>
>
>
>
> IdealAffinityAssignment.calculatePrimaries() calls nodes.size() and then
> divides by that value. Since it is zero, an ArithmeticException: / by zero is
> raised. The error is
> classified as CRITICAL_ERROR and may cause the coordinator JVM to halt.
>
>
>
>
>
> Typical log sequence:
>
>
>
>
>
> ```text
>
>
> Coordinator received all messages, try merge
>
>
> Stop merge, custom event found: DynamicCacheChangeBatch
>
>
> java.lang.ArithmeticException: / by zero
>
>
> ```
>
>
>
>
>
> Relevant stack trace:
>
>
>
>
>
> ```text
>
>
> IdealAffinityAssignment.calculatePrimaries
>
>
> IdealAffinityAssignment.create
>
>
> GridAffinityAssignmentCache.calculate
>
>
> CacheAffinitySharedManager.initAffinityOnNodeJoin
>
>
> CacheAffinitySharedManager.onServerJoinWithExchangeMergeProtocol
>
>
> GridDhtPartitionsExchangeFuture.finishExchangeOnCoordinator
>
>
> ```
>
>
>
>
>
> Steps to reproduce
>
>
>
>
>
> 1. Start one server node and activate the cluster.
>
>
> 2. Start a second server node.
>
>
> 3. Before the node join exchange completes, initiate creation of a new
> partitioned cache group from the first server node.
>
> 4. Allow the coordinator to stop the exchange merge because of the
> DynamicCacheChangeBatch custom event and finish the node join exchange.
>
>
>
>
> Expected behavior
>
>
>
>
>
> The coordinator skips affinity initialization for a cache group whose
> startTopologyVersion is later than the current exchange version. The group is
> initialized by its own exchange.
> No critical failure occurs.
>
>
>
>
>
> Actual behavior
>
>
>
>
>
> The coordinator recalculates affinity using an outdated snapshot with an
> empty affinity node list and fails with ArithmeticException: / by zero.
>
>
>
>
> Suggested fix
>
>
>
>
>
> In CacheAffinitySharedManager.initAffinityOnNodeJoin, skip cache groups
> whose startTopologyVersion is after fut.initialVersion(), similarly to the
> guard introduced for the local
> join path by IGNITE-28806.
>
>
>
>
>
> As additional protection against a coordinator halt,
> IdealAffinityAssignment.calculatePrimaries() could handle nodes == null ||
> nodes.isEmpty() without dividing by zero. This
> defensive change should not replace the topology-version guard, since it
> does not prevent an inconsistent assignment.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)