Repository navigation
SOLR-18094 Support running embedded-zk in "ensemble" mode with new node role - #2391
gerlowskija wants to merge 87 commits into
Conversation
…found" with an out-dated ClusterState (apache#2363)" This reverts commit 5c399dd.
This commit augments our embedded-ZK code to support running embedded-ZK
in "quorum" or ensemble mode. Multiple Solr nodes can now all have
their embedded-ZK's join a multi-node quorum upon startup. Other than
Solr and ZK sharing a process, the embedded- ZK ensemble behaves
identically to one formed of independent processes: nodes can join or
leave the cluster, etc.
Embedded-ensemble-ZK is enabled any time the `zkQuorumRun` system
property is present, along with an explicitly specified ZK host string.
On startup, Solr will identify which host in the zk-conn-string it
should be (based on admittedly hacky heuristics), and then spins up a
'ZooKeeperServerEmbedded' instance in-process to join the ensemble. e.g.
```
export LH="localhost"
bin/solr start -p 8983 -z $LH:9983,$LH:9984,$LH:9985 -DzkQuorumRun
bin/solr start -p 8984 -z $LH:9983,$LH:9984,$LH:9985 -DzkQuorumRun
bin/solr start -p 8985 -z $LH:9983,$LH:9984,$LH:9985 -DzkQuorumRun
```
Some notes:
- this doesn't (yet) work with ZK's dynamic-ensemble feature, so all
ZK nodes must be specified in a static ZK conn string provided at
startup
- this appears to run best when the security-manager is disabled.
|
FYI: https://cwiki.apache.org/confluence/display/SOLR/SIP-14+Embedded+Zookeeper for context on others' interest in moving this direction. |
|
Great work. I think we should rip out the existing embedded ZK, which is a hack. Do you want to proceed in a PR or perhaps in a central feature branch? |
…ion not found" with an out-dated ClusterState (apache#2363)"" This reverts commit 1fb376b.
88c8da4 to
de59401
Compare
|
Spent a few minutes pulling in the latest 'main'. Hoping to give it a bit more cleanup in the next few days if I can, but I've been hoping that for more than a year at this point (😬 ), so if anyone else is interested please feel free to move this forward! |
|
@gerlowskija I took a stab at getting in the use of the solr roles to determine if we hsould run embedded zk quorum mode, and it worked! Here is my start script, where each runs with |
# Conflicts: # solr/core/src/java/org/apache/solr/core/ZkContainer.java # solr/packaging/build.gradle
|
|
FYI, the |
Uses a base class SolrCloudWithEmbeddedZkQuorumTestCase New MiniSolrCloudCluster constructor that spins up a quorum cluster
| " bin/solr assert --not-root" | ||
| " bin/solr assert --not-root", | ||
| "", | ||
| " # Assert a 3-node SolrCloud/ZooKeeper ensemble is fully up before continuing", |
There was a problem hiding this comment.
i don't think we should need the -z here.. We should go to any Solr node and still get the same results...
Test and harden the single-node bootstrap path added in d3b6c74: - MiniSolrCloudCluster: allow a 1-node embedded-ZK quorum. Reserve the ports ZkContainer actually binds (+1000/+1010/+1020, not +1000/+1/+2) and draw candidates from 10000-30000 instead of the OS ephemeral allocator, which on macOS climbs until no port leaves room for the ZK offsets. - TestEmbeddedZkQuorum: replace the 2->3 test with 1->2->3, skipped when the default locale formats integers with non-ASCII digits (ZooKeeper writes its dynamic config in the default locale and can't parse it back). - SolrIgnoredThreadsFilter: ignore ZooKeeper LearnerHandler sender threads left parked in sendPackets. When a leader shuts down, the handler's own shutdown() clears the queued proposal of death, then fails to re-queue it because the thread is interrupted. - ZookeeperStatusHandler: the connection-string mismatch warning no longer claims Solr doesn't support dynamic reconfiguration. - ZkContainer: hoist a computed log argument out of the quorum-wait log call (validateLogCalls), plus formatting. - Ref guide: document the unauthenticated membership changes, quorum-size effects of joins, persistence of ZK data dirs, and the locale requirement as known limitations. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
ExternalZkEnsembleTest runs two Solr containers, built from this tree, against three ZooKeeper containers on one Docker network: it creates and queries a collection, checks the ZK Status page, then stops the ZK leader and checks Solr keeps indexing and querying on the surviving quorum. Run it with './gradlew -p solr/docker dockerExternalZkEnsembleTest'; each Docker test task now filters to its own class. Solr runs in containers too because its ZooKeeper client (Curator's EnsembleTracker with an updatable FixedEnsembleProvider) follows the ensemble config, switching to the zkN:2181 addresses ZooKeeper advertises. Confirmed with bin/solr: a node whose -z listed only one ensemble member kept working after that member stopped. Correct the ZK Status warning and ref guide accordingly: a node's connection string only matters at startup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
|
I went through the ZooKeeper deployment scenarios Solr supports to see which ones we have test coverage for. Embedded single ZK, embedded quorum, external single ZK, ZK ACLs/digest credentials, session expiry and state compression are all covered. These are the gaps I found:
One finding that affects the last few rows and this PR's docs: Solr's ZooKeeper client does follow ensemble changes at runtime. Curator's If I were to add coverage next, I'd start with chroot (a small extension of the external-ensemble test), then TLS, which is the biggest blind spot. Update: I pushed two commits to this branch:
|
…n its real failure
The test indexed as soon as quorum returned, before the surviving node's
ZK client had reconnected; that node's session outlived the outage, so ZK
still showed it live with an active replica while it rejected updates
("Cannot talk to ZooKeeper"). Wait for every node's ZK client to connect,
then for all replicas to be active rather than exactly one, which raced
against recovery succeeding.
What remains is a real failure, so the test stays @AwaitsFix: when the
shard leader is on a stopped node, the Overseer's state-update thread can
stop applying updates after a ConnectionLoss, without logging why, and the
shard never elects a leader. Log a thread dump when recovery times out to
show where that thread is stuck.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
|
I pushed 756bc9f, which looks at
With the race gone, the test still fails in about 2 of 47 runs because of what looks like a real bug, which probably deserves its own JIRA issue: After quorum loss, the Overseer's state-update thread logs The two failures had different triggers:
I haven't yet captured where the thread is stuck. Neither failure happened with the fixed dump in place (the last 32 runs passed). The next failure in a beast or nightly run should show it: |
The note still described the old +1/+2 quorum and election ports. With the +1000/+1010/+1020 offsets, Solr ports must be more than 1020 apart. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
- Share the Docker tests' helpers, constants and Testcontainers thread filter in DockerHelpers, and their Gradle task setup in one closure. - Drop a redundant ZK leader wait from ExternalZkEnsembleTest. - Name ZkContainer's default port offsets and use them in MiniSolrCloudCluster instead of repeating the numbers. - Move the ASCII-digit locale guard into withEmbeddedZkQuorum(), so it covers every embedded-quorum test, not just one. - Smaller tidy-ups in TestEmbeddedZkQuorum and SolrIgnoredThreadsFilter. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
bin/solr start -e cloud now starts node 1 as a one-member ensemble and adds the other members one at a time, instead of starting them all concurrently. That removes the thread pool, the sibling rollback and the per-node DefaultExecutor workaround, and shows the growth flow the ref guide describes. Also fix ExampleTest and test_example.bats, which expected node 2 on SOLR_PORT+1; ensemble nodes are spaced 100 ports apart. They now assert three live nodes with --cloud-nodes 3. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
test_assert.bats gained them alongside --cloud-nodes, but its CATS port didn't. The second node shares the first's Solr home, as in SslTest, so the test needs no shell-specific file commands. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
|
Automated PR readiness judgements (LLM-generated; may be wrong; not updated on later pushes).
|
Use dot-separated names with an explicit unit, per the property naming convention: - solr.zookeeper.server.join.probeTimeoutMs -> join.probe.timeout.ms - solr.zookeeper.server.join.connectTimeoutMs -> join.timeout.ms (it bounds the whole join, not just connecting) - solr.zookeeper.server.quorum.waitLogIntervalMs -> quorum.wait.log.interval.ms Add all three to the Solr Properties Reference, and note there that the client port offset also applies to the standalone embedded ZooKeeper. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm


Description
Here is a video walkthrough of the ZooKeeper/Solr Dynamic Quorum Ensemble: https://share.descript.com/view/Q8dm0VfxNPG
Before this PR, Solr could only run embedded ZooKeeper in "standalone" mode, which can't take part in a larger ensemble and can't survive the loss of its node. There are use cases for an embedded multi-node quorum: development and testing, and adventurous users who want a small fault-tolerant SolrCloud cluster without also deploying ZooKeeper.
See SIP-14 and SOLR-15636 for context.
Solution
Embedded ZK quorum via a new node role
A node with the new
zookeeper_quorum:onnode role starts aZooKeeperServerEmbeddedinstance in-process that takes part in a real ZooKeeper ensemble. Solr works out its ownmyidby matching its host and port against the ZK connection string. Apart from sharing a process with Solr, the ensemble behaves like one made of separate ZK servers.SolrZkServeris removed; the standalone embedded ZK now usesZooKeeperServerEmbeddedtoo.Ports are derived from the Solr port, and each offset can be overridden with a system property:
solr_port + 1000solr.zookeeper.server.client.port.offsetsolr_port + 1010solr.zookeeper.server.quorum.port.offsetsolr_port + 1020solr.zookeeper.server.election.port.offsetTwo ways to form an ensemble
Cold bootstrap: every node lists all members, and nodes wait (logging
still waiting for a quorum) until a majority is up.Start with one node and grow by live joins: a single node comes up as a complete one-member ensemble (
standaloneEnabled=false, so it can be reconfigured later). Later nodes list the existing members plus themselves, sync with the leader, and are added through ZooKeeper dynamic reconfiguration, with no restart of existing nodes. Restarting an existing member reclaims its seat rather than joining again.To allow joins, Solr enables
reconfigEnabled=trueandzookeeper.skipACL=yesfor the embedded server (see Known Limitations).Managing membership
GET /api/cluster/zookeeper/memberslists the members and the config version (zk-readpermission).DELETE /api/cluster/zookeeper/members/{id}?version=...retires a member (newzk-editpermission), and a stale version returns 409.EnsembleTrackeris on by default, and Solr allows server-list updates. A node's-zonly matters at startup. The ZK Status page now says so when-zdiffers from the dynamic ensemble config, instead of claiming that dynamic reconfiguration is unsupported.CLI
bin/solr -e cloudnow forms its own 3-node embedded quorum by default, and asks separately how many extra plain Solr nodes to add. An explicit-zstill uses an external ensemble.bin/solr assert --cloud-nodes N [--solr-url ...]waits for at least N live SolrCloud nodes.Docs
zookeeper-ensemble.adoc: a new "Embedded ZooKeeper Ensemble (Experimental)" section, covering cold bootstrap, single-node growth, port configuration, retiring members and Known Limitations.node-roles.adoc,solr-assert.adoc,solr-properties.adoc,rule-based-authorization-plugin.adoc(zk-edit), and a note inmajor-changes-in-solr-10.adoc.Known limitations (experimental)
zookeeper.skipACL=yesapplies to the whole JVM, and anyone who can reach a ZK client port can add or remove voting members. Keep the ZK ports on a trusted network. When SOLR-18659: Secure embedded ZooKeeper automatically when SSL is on #5329 lands we will actually be able to use teh SSL stuff to authenticate, so we won't need skipACL. And I can live with this limitation if you don't care about security (i.e no SSL)-zis not updated when the ensemble grows. Running nodes follow the new members, but on restart a node can only connect through the hosts it lists.zoo.cfg.dynamic.*) must persist. A node whose ZK data is wiped comes back as a stranger.-zmust exactly matchsolr.host.testQuorumLossAndRecoveryis still@AwaitsFix: in about 4% of runs the Overseer stops applying state updates after quorum loss (see the comments below).Tests
TestEmbeddedZkQuorum:@AwaitsFix, with a race fixed and a thread dump on failure)ZooKeeperEnsembleAPITest/ZooKeeperEnsembleStandaloneTest: the members API.AssertToolTest,test_assert.bats,TestSolrCLIRunExample:assert --cloud-nodesand the new-e cloud.ExternalZkEnsembleTest(new, Testcontainers): 3 ZooKeeper containers and 2 Solr containers built from the tree. It covers collection creation, indexing and querying across nodes, and stopping the ZK leader. Run it with./gradlew -p solr/docker dockerExternalZkEnsembleTest.MiniSolrCloudCluster.Builder.withEmbeddedZkQuorum(n), which now accepts 1 node.SolrIgnoredThreadsFilterentry for a ZooKeeperLearnerHandlersender-thread leak.Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.