ispringer opened a new pull request, #5385:
URL: https://github.com/apache/solr/pull/5385

   https://issues.apache.org/jira/browse/SOLR-18686
   
   # Description
   
   Every node sends the Overseer a `downnode` message when it starts, stops 
cleanly or reconnects. `NodeMutator.downNode` answers it by resolving every 
collection in the cluster through `collectionStream()`. Each lazily loaded 
collection costs a ZooKeeper read, serially, on the thread that applies every 
other cluster state change. On clusters with thousands of collections, a 
rolling restart or mass shutdown sends thousands of these messages, and the 
state update queue backs up behind them. See the JIRA issue for details.
   
   # Solution
   
   - `ZkController.publishNodeAsDown` already builds the list of collections 
the node has replicas in. It now adds that list to the `downnode` message as 
`collections`.
   - With the new cluster property `useListedCollectionsOnlyForDownNode` set to 
`true`, `NodeMutator.downNode` reads only the listed collections. A listed 
collection that no longer exists is skipped, and an empty list reads nothing. A 
message without the list (from an older node) falls back to the full scan.
   - The property is off by default and read when each message is handled, so 
`CLUSTERPROP` turns it on or off without a restart. It's registered in 
`ZkStateReader.KNOWN_CLUSTER_PROPS`.
   - Mixed versions work in either direction: an older Overseer ignores the 
extra property, and a newer Overseer scans everything for a message without the 
list.
   - Distributed cluster state updates are unchanged.
   
   What it can miss: a replica added to the node, in a collection the node had 
no replica in, after the node built its list and before the Overseer handles 
the message. That replica keeps the state it was added with while the node is 
absent from `live_nodes`, which is what an unclean exit already leaves behind. 
That window is why the change is behind a switch; I'm open to making it the 
default.
   
   Benchmark (embedded ZooKeeper, laptop, JDK 21): about 5,000 collections 
across 2,000 nodes, with 2,900 `downnode` messages queued before the Overseer 
starts. Draining the queue took 728 s (251 ms per message) with the property 
off, and 6.7 s (2.3 ms per message) with it on. The final replica states were 
identical.
   
   I used Claude Code to help write and port this change and its tests. I 
reviewed the result.
   
   # Tests
   
   - `NodeMutatorTest.downNodeLoadsOnlyTheCollectionsTheMessageLists`: with the 
property unset or `false`, the list is ignored. With it `true`, only the listed 
collections are loaded (checked with `CollectionRef.getCount()`) and written. A 
missing collection is ignored, an empty list loads nothing, a message without 
the list scans every collection, and a value that isn't a list throws 
`ClassCastException`.
   - `OverseerTest.testDownNodeReadsOnlyCollectionsListedInMessage`: with the 
property set in ZooKeeper and through the real state update queue, a `downnode` 
that lists one of the node's two collections marks only that one DOWN, and a 
`downnode` without the list then marks the other.
   - `ZkControllerTest.testPublishAndWaitForDownStates` now runs with the 
property on, so when it uses the Overseer, the replica goes DOWN only if 
`publishNodeAsDown` sent the right list.
   
   Ran `./gradlew :solr:core:test --tests 
"org.apache.solr.cloud.NodeMutatorTest" --tests 
"org.apache.solr.cloud.OverseerTest" --tests 
"org.apache.solr.cloud.ZkControllerTest"` (31 tests, 3 skipped, 0 failures) 
plus `forbiddenApis` and `spotlessCheck` on the touched modules, on JDK 21.
   
   # Checklist
   
   - [x] I have reviewed the guidelines for [How to 
Contribute](https://github.com/apache/solr/blob/main/CONTRIBUTING.md) and my 
code conforms to the standards described there to the best of my ability.
   - [x] I have created a Jira issue and added the issue ID to my pull request 
title.
   - [x] I have given Solr maintainers 
[access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
 to contribute to my PR branch. (optional but recommended, not available for 
branches on forks living under an organisation)
   - [x] I have developed this patch against the `main` branch.
   - [x] I have run `./gradlew check`.
   - [x] I have added tests for my changes.
   - [ ] I have added documentation for the [Reference 
Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   - [x] I have added a [changelog 
entry](https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc) for my 
change
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to