Skip to content

SOLR-17720: Fix deadlock possibility in CollectionPropertiesZkStateReader #3304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aparnasuresh85
Copy link
Contributor

https://issues.apache.org/jira/browse/SOLR-17720

Description

Please provide a short description of the changes you're making with this pull request.

Fix deadlock possibility in CollectionPropertiesZkStateReader

Please provide a short description of the approach taken to implement your solution.

The deadlock occurs due to conflicting lock acquisition orders between removeCollectionPropsWatcher() and refreshAndWatch():

removeCollectionPropsWatcher() first locks collectionPropsObservers via compute(collection, ), then waits on getCollectionLock(collection).

refreshAndWatch() first locks getCollectionLock(coll), then waits on collectionPropsObservers.remove(coll).

To resolve this, the fix moves the synchronized (getCollectionLock(collection)) block outside the compute() call in removeCollectionPropsWatcher(), ensuring a consistent lock order and preventing deadlock. While the overall locking logic could be simplified further, this change specifically addresses the deadlock scenario.

Tests

No new tests introduced. Ensure existing tests pass.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aparnasuresh85 , looks like you accidentally added a temp file.

Otherwise, this looks good! Straight-forward fix/PR. Just needs a CHANGES.txt file in bug fix section for 9.9

@dsmiley
Copy link
Contributor

dsmiley commented Apr 10, 2025

Once those things are done, I'll merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants