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

   https://issues.apache.org/jira/browse/SOLR-18562
   
   # Description
   
   When the first document arrives for a time routed alias with date math in 
`router.start`, `TimeRoutedAlias.validateRouteValue()` fixes the start and 
writes it to `aliases.json` asynchronously. The modification function passed to 
`applyModificationAndExportToZk()` ignores its argument and returns a clone of 
the aliases snapshot taken earlier. If `aliases.json` changed in between, the 
CAS fails, the retry reads the current version, and the function returns the 
old snapshot again, which then gets written. Any alias created after the 
snapshot is lost.
   
   # Solution
   
   Build the change on the aliases passed to the function (like every other 
caller of `applyModificationAndExportToZk`), and set only `router.start`:
   
   ```java
   (a) -> a.cloneWithCollectionAliasProperties(aliasName, ROUTER_START, 
fixedStart)
   ```
   
   Notes:
   - Before, the whole property map of the alias was copied from the snapshot, 
so a concurrent change to another property of the same alias could also be 
reverted. Setting only `router.start` avoids that.
   - If the alias itself is deleted before the asynchronous write runs, 
`cloneWithCollectionAliasProperties` now throws "is not a valid alias" in the 
background task instead of writing the snapshot back (which would have 
recreated the deleted alias). The document is not affected, since this runs 
asynchronously.
   - Two nodes fixing the start at the same time can still pick slightly 
different instants (the existing comment about who wins); this PR doesn't 
change that.
   
   # Tests
   
   Added `CreateRoutedAliasTest.testFixingStartKeepsOtherAliases`: it creates a 
time routed alias with `start=NOW/DAY`, creates a second alias, puts the 
hosting node's cached aliases back to before the second alias existed (with 
reflection, under `@SuppressForbidden`, since there is no hook to delay a watch 
event), and sends the first document to that node. It then checks that 
`router.start` was fixed and the second alias still exists.
   
   The test fails on main (the second alias is gone: `expected:<...> but 
was:<null>`) and passes with the fix (also 5 more runs with different seeds). 
`CreateRoutedAliasTest` and `AliasIntegrationTest` pass, and so does `./gradlew 
:solr:core:check -x test`. I didn't put it in 
`TimeRoutedAliasUpdateProcessorTest` because that class is `@AwaitsFix` 
(SOLR-13059), and so is its `testDateMathInStart` (SOLR-13943).
   
   # 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