Repository navigation
SOLR-18601: Undo the routing rule and buffering when a MIGRATE fails - #5253
Open
SpookyJumpyBeans wants to merge 1 commit into
Open
SpookyJumpyBeans wants to merge 1 commit into
SpookyJumpyBeans wants to merge 1 commit into
Conversation
MIGRATE asks the target leader to buffer updates and adds a routing rule to the source shard before the steps that can fail (creating the temporary collection, splitting, adding a replica, merging). A failure in any of them left the target leader buffering, so forwarded updates were never searchable on the target and a retry failed immediately. On such a failure, remove the routing rule, wait for the removal, and drop the target leader's buffered updates. This adds an internal REQUESTDROPBUFFEREDUPDATES core admin action, next to REQUESTBUFFERUPDATES and REQUESTAPPLYUPDATES.
SpookyJumpyBeans
added a commit
to SpookyJumpyBeans/boyidai
that referenced
this pull request
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/SOLR-18601
Description
MigrateCmdasks the target leader to buffer updates and adds a routing rule to the source shard before creating a temporary collection, splitting into it and merging into the target. If any of those steps fails, the exception propagates with the target leader still buffering and the routing rule still in place. Updates forwarded under the rule are buffered and never become searchable on the target, and a retry fails immediately becauseREQUESTBUFFERUPDATESrequires the target's update log to beACTIVE.Solution
The steps between buffering and applying the buffered updates are wrapped in a
try. On failure,cleanupFailedMigrate()removes the routing rule, waits for the removal to be visible (updates forwarded until then would otherwise be indexed by the target once it stops buffering), and then asks the target leader to drop its buffered updates. Errors during cleanup are added to the original exception as suppressed exceptions; anInterruptedExceptionskips cleanup and keeps the interrupt flag.Dropping, rather than applying, the buffered updates puts the target back in its pre-MIGRATE state. The documents aren't lost: the source shard leader indexes them and sends them to its own replicas as usual, and forwarding to the MIGRATE target is an additional copy (
DistributedZkUpdateProcessor.doDistribAdd/doDistribDeleteById).There was no core admin action to drop buffered updates (
UpdateLog.dropBufferedUpdates()exists but had no callers), so this addsREQUESTDROPBUFFEREDUPDATES, next toREQUESTBUFFERUPDATESandREQUESTAPPLYUPDATESand modeled on them (missing core is a 400, not buffering is a 500, unexpected errors are wrapped in a 500).Notes:
MigrateCmddiff is re-indentation for the newtryblock; it's much smaller with whitespace ignored.REQUESTAPPLYUPDATESitself isn't covered: by then the target has the merged index, and dropping the buffer would lose updates made during the MIGRATE.ShardRequestTracker.processResponsesonly records the failure), so some failures still let it run to the end.Tests
Added
MigrateRouteKeyTest.testRetryAfterFailedMigrate. It makes MIGRATE fail after the target leader started buffering: an alias refers to a leftover temporary collection, so MIGRATE can't delete it and then fails to create it. It does this once synchronously and once asynchronously, and after each checks that the target leader's update log isACTIVEand the routing rule is gone. It then removes the alias, retries the MIGRATE, and checks that the target has exactly the migrated documents.Without the fix, both the synchronous and the asynchronous failure leave the target leader in
BUFFERING(expected:<ACTIVE> but was:<BUFFERING>), and a retry fails with "MIGRATE failed to request node to buffer updates". With the fix,MigrateRouteKeyTestpasses on 3 runs with different seeds. Also added tests for the new action's error handling toCoreAdminOperationTest.CoreAdminOperationTest,CoreAdminHandlerTestandV2CoreAPIMappingTestpass, and so does./gradlew :solr:solrj:check :solr:core:check -x test.Checklist
mainbranch../gradlew check.