This is an automated email from the ASF dual-hosted git repository. houston pushed a commit to branch branch_9x in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push: new e606c5c450d SOLR-17860: Support PULL replicas in DocBasedVersionConstraintsProcessor (#3471) e606c5c450d is described below commit e606c5c450d88342f6a48981409a47be6de97bc3 Author: Houston Putman <hous...@apache.org> AuthorDate: Thu Aug 21 11:09:52 2025 -0700 SOLR-17860: Support PULL replicas in DocBasedVersionConstraintsProcessor (#3471) (cherry picked from commit 26ad021d0776fc950afa9216475a1bd945bbc5c7) --- solr/CHANGES.txt | 2 +- ...DocBasedVersionConstraintsProcessorFactory.java | 15 ++++++++++----- .../solr/cloud/TestDistribDocBasedVersion.java | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index d562358f6e1..9f6aed27a9a 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -11,7 +11,7 @@ New Features Improvements --------------------- -(No changes) +* SOLR-17860: DocBasedVersionConstraintsProcessorFactory now supports PULL replicas. (Houston Putman) Optimizations --------------------- diff --git a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java index 1088d3280de..c7fbcc88892 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java @@ -170,15 +170,20 @@ public class DocBasedVersionConstraintsProcessorFactory extends UpdateRequestPro @Override public void inform(SolrCore core) { - - if (core.getUpdateHandler().getUpdateLog() == null) { - throw new SolrException(SERVER_ERROR, "updateLog must be enabled."); - } - if (core.getLatestSchema().getUniqueKeyField() == null) { throw new SolrException(SERVER_ERROR, "schema must have uniqueKey defined."); } + // We can only be sure that no-update-log is safe if the core is a SolrCloud replica and is not + // leader eligible, because those cores will all have the "isNotLeader()" return true, and the + // URP logic will be ignored. Otherwise, we need to ensure an update log exists. + if (core.getCoreDescriptor().getCloudDescriptor() == null + || core.getCoreDescriptor().getCloudDescriptor().getReplicaType().leaderEligible) { + if (core.getUpdateHandler().getUpdateLog() == null) { + throw new SolrException(SERVER_ERROR, "updateLog must be enabled."); + } + } + useFieldCache = true; for (String versionField : versionFields) { SchemaField userVersionField = core.getLatestSchema().getField(versionField); diff --git a/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java b/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java index a0fc4b2b988..2efdb51ccde 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java @@ -21,10 +21,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.solr.client.solrj.SolrClient; +import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.UpdateRequest; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrException; +import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.util.StrUtils; import org.junit.BeforeClass; import org.junit.Test; @@ -108,6 +110,26 @@ public class TestDistribDocBasedVersion extends AbstractFullDistribZkTestBase { } } + @Test + public void testPullReplica() throws Exception { + try { + CollectionAdminRequest.addReplicaToShard(DEFAULT_COLLECTION, "shard1") + .setType(Replica.Type.PULL) + .process(cloudClient); + } finally { + List<Replica> pullReplicas = + cloudClient + .getClusterStateProvider() + .getCollection(DEFAULT_COLLECTION) + .getSlice("shard1") + .getReplicas(r -> r.getType().equals(Replica.Type.PULL)); + for (Replica replica : pullReplicas) { + CollectionAdminRequest.deleteReplica(DEFAULT_COLLECTION, "shard1", replica.getName()) + .process(cloudClient); + } + } + } + private void doTestHardFail() throws Exception { log.info("### STARTING doTestHardFail");