Skip to content

[8.19] Avoid stack overflow in IndicesClusterStateService applyClusterState#139499

Merged
elasticsearchmachine merged 2 commits intoelastic:8.19from
albertzaharovits:backport-819-132536
Dec 14, 2025
Merged

[8.19] Avoid stack overflow in IndicesClusterStateService applyClusterState#139499
elasticsearchmachine merged 2 commits intoelastic:8.19from
albertzaharovits:backport-819-132536

Conversation

@albertzaharovits
Copy link
Contributor

Backport of #132536

Every cluster state applied in the IndicesClusterStateService has the potential to chain a new RefCountingListener to a chain of such listeners. If the chain is too long, the unlucky thread that decreases the ref count to 0 for the head of the listeners chain, ends up calling each listener in turn, and, assuming all ref counts are hence decreased to 0, traversing the whole chain on its thread stack, possibly resulting in a Stackoverflow exception.

This fix chains max 10 RefCountingListener, the 11th one is forked on a generic thread when it gets to execution.

…lastic#132536)

Every cluster state applied in the IndicesClusterStateService has the potential to chain a new RefCountingListener to a chain of such listeners. If the chain is too long, the unlucky thread that decreases the ref count to 0 for the head of the listeners chain, ends up calling each listener in turn, and, assuming all ref counts are hence decreased to 0, traversing the whole chain on its thread stack, possibly resulting in a Stackoverflow exception.

This fix chains max 8 RefCountingListener, the 11th one is forked on a generic thread when it gets to execution.
@albertzaharovits albertzaharovits self-assigned this Dec 14, 2025
@albertzaharovits albertzaharovits added >bug :Distributed/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. backport auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) v8.19.10 labels Dec 14, 2025
@elasticsearchmachine elasticsearchmachine merged commit d70ec70 into elastic:8.19 Dec 14, 2025
28 checks passed
@albertzaharovits albertzaharovits deleted the backport-819-132536 branch December 14, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport >bug :Distributed/Cluster Coordination Cluster formation and cluster state publication, including cluster membership and fault detection. v8.19.10

2 participants