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

   https://issues.apache.org/jira/browse/SOLR-18612
   
   Follow-up to #5407, as discussed there with @dsmiley: the `success` and 
`failure` sections of Collections API responses were not JSON-compatible maps. 
This PR stacks on #5407 until that merges; the diff below the top commit is the 
one under review here.
   
   # Description
   
   Inside `success` / `failure`, sub-requests were keyed by node name, or 
`node/replica` when the caller passed a replica, and several requests 
legitimately shared a key: `SPLITSHARD` sends `CREATE` and 
`REQUESTAPPLYUPDATES` to the same sub-shard core, `MIGRATE` sends several 
actions to the same leader, and `AddReplicaCmd` sends core creates before a 
replica name exists, so they were keyed by node alone. The entries sat in a 
`SimpleOrderedMap` with repeated keys, which renders as duplicate JSON 
properties, collapses in `REQUESTSTATUS` (it copies the stored entries into a 
map), and hides all but the first failure from 
`CollectionAdminResponse.getErrorMessages()`.
   
   # Solution
   
   - **One key per sub-request**: `node/core/action`. 
`ShardRequestTracker.sendShardRequest` records the target core (the caller's 
core name, or `replica.getCoreName()`) and the request's `action` parameter on 
the `ShardRequest`; `processResponse` and the async completion wait build the 
key from those. `AsyncCmdInfo` carries the same identity. 
`TestRequestStatusCollectionAPI` now asserts the key shape and keeps expecting 
7 distinct `SPLITSHARD` sub-responses.
   - **Real maps**: `successMap` / `failureMap` from #5407 are declared as 
`Map<String, Object>` and backed by a `LinkedHashMap`; every server-side reader 
uses the `Map` API (`values()`, `putAll`, `isEmpty`) instead of casting to 
`NamedList` and indexing by position (`BackupCmd`, `CreateCollectionCmd`, 
`CreateSnapshotCmd`, `DeleteSnapshotCmd`, `SplitShardCmd`, 
`InstallShardDataCmd`, `CollectionsHandler`, and the merges in 
`CreateShardCmd`, `RestoreCmd`, `DeleteShardCmd`, `ReplicaMigrationUtils`). 
`MAINTAINROUTEDALIAS`'s `create` entry follows.
   - **SolrJ**: `CollectionAdminResponse.getCollectionStatus()` returns 
`Map<String, NamedList<Object>>` and `getErrorMessages()` returns `Map<String, 
Object>`; javabin decodes a plain map as `LinkedHashMap` by default, so the old 
`NamedList` casts would have failed. `getCollectionCoresStatus()` is unchanged; 
`getCollectionNodesStatus()` still keys by node, taken from the new key.
   - **Docs**: upgrade note (API Changes and SolrJ), the ref-guide examples 
that showed node-only keys (`ADDREPLICA`, `DELETE`, the films tutorial), 
changelog.
   
   AI disclosure: the investigation, the edits and this description were 
drafted with Claude Code and reviewed by me.
   
   # Tests
   
   - `TestRequestStatusCollectionAPI` asserts every sub-request key is 
`node/core/action` and still finds all 7 `SPLITSHARD` sub-responses (this test 
fails with a plain map and the old keys: 7 collapse to 3).
   - Existing suites adapted to the `Map` type: 
`AsyncCallRequestStatusResponseTest`, `DeleteShardTest`, `DeleteReplicaTest`.
   - Ran the suites that read these sections or the changed accessors: 
`TestRequestStatusCollectionAPI`, `AsyncCallRequestStatusResponseTest`, 
`DeleteShardTest`, `DeleteReplicaTest`, `CollectionsAPISolrJTest`, 
`CollectionsAPIDistributedZkTest`, `TestCollectionAPI`, 
`TestCollectionsAPIViaSolrCloudCluster`, `BasicDistributedZkTest`, 
`LocalFSInstallShardTest`, `CreateCollectionCleanupTest`, 
`TestLocalFSCloudBackupRestore`, `SplitByPrefixTest`, `TestRequestForwarding`, 
`MigrateRouteKeyTest`, `MigrateReplicasTest`, `ReplaceNodeTest`, 
`TestConfigSetsAPI`: 156 tests, all pass (`ShardSplitTest` is `@Nightly` and 
did not run). Plus `./gradlew check -x test`.
   
   # Checklist
   
   Please review the following and check all that apply:
   
   - [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.
   - [x] I have added documentation for the [Reference 
Guide](https://github.com/apache/solr/tree/main/solr/solr-ref-guide)
   


-- 
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