SpookyJumpyBeans opened a new pull request, #5186: URL: https://github.com/apache/solr/pull/5186
https://issues.apache.org/jira/browse/SOLR-18557 # Description When a REINDEXCOLLECTION is aborted or fails, `cleanup()` deletes the target and checkpoint collections before it turns readOnly off on the source and removes the reindexing state. If deleting the target throws (for example, because an alias references it), the source collection stays read-only. # Solution The readOnly reset and `removeReindexingState` now run in a `finally` block, so the source collection is restored even if the temporary collections can't be deleted. The delete error is still rethrown, so the async request is still reported as failed with the alias message. ```java try { // delete target collection // delete checkpoint collection } finally { // turn readOnly off on the source collection removeReindexingState(collection); } ``` Most of the diff is re-indentation; viewing it with "Hide whitespace" shows the actual change. Notes: - If deleting the target fails, the checkpoint collection is not deleted either. That one is self-healing, because the next REINDEXCOLLECTION run deletes an existing checkpoint collection before starting. - The aliased target collection is intentionally left in place, since something else references it. - In the in-place mode, the command's own `<source> -> <target>` alias can also block the delete if a failure happens after it is created. This PR restores the source in that case too, but it doesn't remove that alias; whether cleanup should undo it seems like a separate question. - If the readOnly reset itself also fails, its exception replaces the delete error (plain `finally` semantics). I kept it simple since the reset is the more important failure to surface. # Tests Added `ReindexCollectionTest.testAbortWithAliasedTarget`: 1. Pause a reindex at the existing latch. 2. Alias the target. 3. Abort the reindex. 4. Check that the source is writable again, that its reindexing state is cleared, and that the async request reports FAILED. The test fails on main ("source collection is in wrong state", with "is part of aliases" in the log) and passes with the fix. All 7 tests in `ReindexCollectionTest` pass, and so does `./gradlew :solr:core:check -x test`. # 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]
