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

   https://issues.apache.org/jira/browse/SOLR-18559
   
   # Description
   
   `RoutedAliasUpdateProcessor` reads the routed alias properties only from the 
node's cached aliases. If that cache is stale (for example, after a missed 
watch on `/aliases.json`), updates to the alias fail with "Routed alias ... 
appears to have been removed during request processing", even though the alias 
exists in ZooKeeper.
   
   # Solution
   
   When the alias isn't in the cache, `getAliasProps()` now calls 
`AliasesManager.update()` (which syncs with ZK first) and checks again before 
failing. This matches what `HttpSolrCall` and `RoutedAlias` already do when 
they can't find an alias.
   
   ```java
   if (aliasProperties.isEmpty()) {
     // our cached aliases may be stale (e.g. a watch was missed), so check ZK 
before failing
     zkStateReader.aliasesManager.update();
     aliasProperties = 
zkStateReader.getAliases().getCollectionAliasProperties(aliasName);
   }
   ```
   
   Notes:
   - The refresh only happens when the alias isn't found, so the normal update 
path is unchanged. If the alias was really deleted, the request now does one ZK 
read before failing.
   - This doesn't change how `AliasesManager` handles a connection loss during 
watch processing (it logs and doesn't re-register the watch). The other 
watchers in `ZkStateReader` do the same, so that seemed better as a separate 
issue.
   
   # Tests
   
   Added `CreateRoutedAliasTest.testUpdateOnNodeWithStaleAliases`: it creates a 
time routed alias, waits for the hosting node to catch up with `aliases.json`, 
then resets that node's cached aliases and sends it an update. The cache is 
reset with reflection (under `@SuppressForbidden`, like 
`AsyncTrackerSemaphoreLeakTest`) because there is no hook for it: removing the 
ZK watch doesn't work, since `AliasesManager` re-reads and re-registers on the 
`DataWatchRemoved` event.
   
   The test fails on main with "Routed alias ... appears to have been removed 
during request processing" and passes with the fix (also 6 more runs with 
different seeds). `CreateRoutedAliasTest` and `AliasIntegrationTest` pass, and 
so does `./gradlew :solr:core:check -x test`. I didn't add it to 
`TimeRoutedAliasUpdateProcessorTest` because that class is `@AwaitsFix` 
(SOLR-13059).
   
   # Checklist
   
   - [x] I have reviewed the guidelines for How to Contribute 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 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
   - [x] I have added a changelog entry for my change
   


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