This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
commit c3f7e733ced594a4190e9fc920edc383ac749ff7 Author: julia-maimone <[email protected]> AuthorDate: Fri Oct 6 01:46:12 2023 -0300 SOLR-16924: RESTORECORE: make UpdateLog ACTIVE without requiring REQUESTAPPLYUPDATES (#1965) RESTORECORE now sets the UpdateLog to ACTIVE state instead of requiring a separate REQUESTAPPLYUPDATES call in Collection restore. The latter will still happen in 9.x for backwards-compatibility. --------- Co-authored-by: Julia Maimone <[email protected]> Co-authored-by: David Smiley <[email protected]> --- solr/CHANGES.txt | 4 ++- .../solr/cloud/api/collections/RestoreCmd.java | 32 ---------------------- .../apache/solr/handler/admin/api/RestoreCore.java | 7 +++++ 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index a1c85c938b2..d2721465dd8 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -12,7 +12,9 @@ New Features Improvements --------------------- -(No changes) +* SOLR-16924: RESTORECORE now sets the UpdateLog to ACTIVE state instead of requiring a separate + REQUESTAPPLYUPDATES call in Collection restore. The latter will still happen in 9.x for + backwards-compatibility. (Julia Lamoine, David Smiley) Optimizations --------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java index 2140078ed1e..7621750a5f5 100644 --- a/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java +++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/RestoreCmd.java @@ -300,7 +300,6 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand { rc.repo, rc.shardHandler, rc.asyncId); - requestReplicasToApplyBufferUpdates(restoreCollection, rc.asyncId, rc.shardHandler); markAllShardsAsActive(restoreCollection); addReplicasToShards(results, clusterState, restoreCollection, replicaPositions, rc.asyncId); restoringAlias(rc.backupProperties); @@ -527,37 +526,6 @@ public class RestoreCmd implements CollApiCmds.CollectionApiCommand { } } - private void requestReplicasToApplyBufferUpdates( - DocCollection restoreCollection, String asyncId, ShardHandler shardHandler) { - ShardRequestTracker shardRequestTracker = - CollectionHandlingUtils.asyncRequestTracker(asyncId, ccc); - - for (Slice s : restoreCollection.getSlices()) { - for (Replica r : s.getReplicas()) { - String nodeName = r.getNodeName(); - String coreNodeName = r.getCoreName(); - Replica.State stateRep = r.getState(); - - log.debug( - "Calling REQUESTAPPLYUPDATES on: nodeName={}, coreNodeName={}, state={}", - nodeName, - coreNodeName, - stateRep); - - ModifiableSolrParams params = new ModifiableSolrParams(); - params.set( - CoreAdminParams.ACTION, - CoreAdminParams.CoreAdminAction.REQUESTAPPLYUPDATES.toString()); - params.set(CoreAdminParams.NAME, coreNodeName); - - shardRequestTracker.sendShardRequest(nodeName, params, shardHandler); - } - - shardRequestTracker.processResponses( - new NamedList<>(), shardHandler, true, "REQUESTAPPLYUPDATES calls did not succeed"); - } - } - // Mark all shards in ACTIVE STATE private void markAllShardsAsActive(DocCollection restoreCollection) throws KeeperException, InterruptedException { diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCore.java b/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCore.java index 9cfbdf64460..858e42da9f6 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCore.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/api/RestoreCore.java @@ -34,6 +34,7 @@ import org.apache.solr.handler.admin.CoreAdminHandler; import org.apache.solr.jersey.PermissionName; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.SolrQueryResponse; +import org.apache.solr.update.UpdateLog; /** * V2 API implementation for restoring a previously taken backup to a core @@ -137,6 +138,12 @@ public class RestoreCore extends CoreAdminAPIBase implements RestoreCoreApi { .getZkController() .getShardTerms(cd.getCollectionName(), cd.getShardId()) .ensureHighestTermsAreNotZero(); + + // transitions state of update log to ACTIVE + UpdateLog updateLog = core.getUpdateHandler().getUpdateLog(); + if (updateLog != null) { + updateLog.applyBufferedUpdates(); + } } }
