-
Notifications
You must be signed in to change notification settings - Fork 722
SOLR-17704: Refactor and use curator for distributed locks #3345
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing, Haythem!
I noticed that you renamed the classes to replace "Zk" with "Curator". But Curator is more of an implementation choice. Fundamentally, the locks are in ZooKeeper; the existing names made sense. As Solr uses Curator more and more, I don't think we need to follow this renaming pattern of Curator showing up in class names.
Overall, this PR isn't what I expected. I expected to see usage of Curator recipes that would thus save us from maintaining lower level code (whether it be ZK level of Curator "framework" level). But I don't see that at all; although a comment hints at it but I don't see it in the code. I just see some basic swap-outs of "framework" level Curator which is basically 1:1 to ZooKeeper, with barely any value-add. Consequently, there isn't much point to this PR as it stands. I take responsibility for not underscoring the intent in the vague JIRA description.
The PR description says a lot; it led me to believe that there is much more going on here than there is. It said things that were probably true previously. I suspect an LLM wrote it; and the LLM didn't recognize the refactoring nature here. Even if my hunch is correct, you are always responsible for the LLM's output, be it code, PRs, or documentation as if you wrote it yourself. If you had included an LLM generated disclaimer, with a horizontal line separating your commentary from the LLM, then that would help readers know the trustworthiness of the parts of the PR text.
@@ -47,7 +47,8 @@ public void monothreadedApiLockTests() throws Exception { | |||
.build()) { | |||
ConfigSetApiLockFactory apiLockFactory = | |||
new ConfigSetApiLockFactory( | |||
new ZkDistributedConfigSetLockFactory(zkClient, "/apiLockTestRoot")); | |||
new CuratorDistributedConfigSetLockFactory( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it was reasonable to pass SolrZkClient; consider as a convenience constructor. This relates to my view as Curator as an implementation detail.
* <p>Each config set has its own lock directory under the root path. This is distinct from the | ||
* collection lock factory, which supports hierarchical locking for collections, shards, and | ||
* replicas. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to say this at all; I wouldn't.
* znode hierarchy, for use with the distributed Collection API implementation. The locks are | ||
* implemented using ephemeral nodes placed below the "directory" nodes. | ||
* A distributed lock factory for Solr collections, shards, and replicas, using Apache Curator's | ||
* {@link org.apache.curator.framework.recipes.locks.InterProcessReadWriteLock} to manage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the usage of InterProcessReadWriteLock.
https://issues.apache.org/jira/browse/SOLR-17704
Description
This PR refactors Solr's distributed lock implementation to use Curator's ZK primitives for all ZooKeeper operations, while preserving the legacy Solr lock semantics. The new implementation, CuratorDistributedLocks, replaces the previous use of Curator's high-level lock recipes and closely matches the behavior of the old ZkDistributedLock, ensuring that read locks are only blocked by lower-numbered write locks and write locks are blocked by any lower-numbered lock. The lock acquisition strategy is documented and explained in the code.
Solution
Tests
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.