Boyi Dai created SOLR-18557:
-------------------------------

             Summary: REINDEXCOLLECTION abort/failure can leave the source 
collection read-only
                 Key: SOLR-18557
                 URL: https://issues.apache.org/jira/browse/SOLR-18557
             Project: Solr
          Issue Type: Bug
          Components: SolrCloud
            Reporter: Boyi Dai


When REINDEXCOLLECTION is aborted or fails, ReindexCollectionCmd.cleanup() runs 
these steps in order:
# delete the target collection
# delete the checkpoint collection
# turn readOnly off on the source collection
# remove the reindexing state

If step 1 or 2 throws, steps 3 and 4 never run. The source collection then 
stays read-only, and its reindexing state is left behind.

One way step 1 throws: the target collection is referenced by an alias. 
DeleteCollectionCmd then refuses with "Collection : X is part of aliases: 
[...], remove or modify the aliases before removing this collection." Two ways 
this happens:
* A user creates an alias on the target while the reindex runs. 
REINDEXCOLLECTION doesn't take a collection lock, so CREATEALIAS can run 
concurrently.
* With the default in-place mode (no explicit target), the command creates the 
alias <source> -> <target> itself. A failure after that point hits the same 
error during cleanup.

*Steps to reproduce:*
# Start an async REINDEXCOLLECTION of collection A with target B.
# While it is running, CREATEALIAS C -> B.
# Abort the reindex (cmd=abort).
# Result: B is kept (expected, since it is aliased), but A stays readOnly=true 
and /collections/A/.reindexing is not removed.

*Expected:* the source collection is always restored, even when the temporary 
collections can't be removed.

*Proposed fix:* run the readOnly reset and the reindexing-state removal in a 
finally block, and keep rethrowing the delete error so the failure is still 
reported. I have a patch with a test and will open a PR.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to