Skip to content

Commit e606c5c

Browse files
committed
SOLR-17860: Support PULL replicas in DocBasedVersionConstraintsProcessor (#3471)
(cherry picked from commit 26ad021)
1 parent 764aff6 commit e606c5c

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

solr/CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ New Features
1111

1212
Improvements
1313
---------------------
14-
(No changes)
14+
* SOLR-17860: DocBasedVersionConstraintsProcessorFactory now supports PULL replicas. (Houston Putman)
1515

1616
Optimizations
1717
---------------------

solr/core/src/java/org/apache/solr/update/processor/DocBasedVersionConstraintsProcessorFactory.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,20 @@ public UpdateRequestProcessor getInstance(
170170

171171
@Override
172172
public void inform(SolrCore core) {
173-
174-
if (core.getUpdateHandler().getUpdateLog() == null) {
175-
throw new SolrException(SERVER_ERROR, "updateLog must be enabled.");
176-
}
177-
178173
if (core.getLatestSchema().getUniqueKeyField() == null) {
179174
throw new SolrException(SERVER_ERROR, "schema must have uniqueKey defined.");
180175
}
181176

177+
// We can only be sure that no-update-log is safe if the core is a SolrCloud replica and is not
178+
// leader eligible, because those cores will all have the "isNotLeader()" return true, and the
179+
// URP logic will be ignored. Otherwise, we need to ensure an update log exists.
180+
if (core.getCoreDescriptor().getCloudDescriptor() == null
181+
|| core.getCoreDescriptor().getCloudDescriptor().getReplicaType().leaderEligible) {
182+
if (core.getUpdateHandler().getUpdateLog() == null) {
183+
throw new SolrException(SERVER_ERROR, "updateLog must be enabled.");
184+
}
185+
}
186+
182187
useFieldCache = true;
183188
for (String versionField : versionFields) {
184189
SchemaField userVersionField = core.getLatestSchema().getField(versionField);

solr/core/src/test/org/apache/solr/cloud/TestDistribDocBasedVersion.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import org.apache.solr.client.solrj.SolrClient;
24+
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
2425
import org.apache.solr.client.solrj.request.UpdateRequest;
2526
import org.apache.solr.client.solrj.response.QueryResponse;
2627
import org.apache.solr.common.SolrDocument;
2728
import org.apache.solr.common.SolrException;
29+
import org.apache.solr.common.cloud.Replica;
2830
import org.apache.solr.common.util.StrUtils;
2931
import org.junit.BeforeClass;
3032
import org.junit.Test;
@@ -108,6 +110,26 @@ public void test() throws Exception {
108110
}
109111
}
110112

113+
@Test
114+
public void testPullReplica() throws Exception {
115+
try {
116+
CollectionAdminRequest.addReplicaToShard(DEFAULT_COLLECTION, "shard1")
117+
.setType(Replica.Type.PULL)
118+
.process(cloudClient);
119+
} finally {
120+
List<Replica> pullReplicas =
121+
cloudClient
122+
.getClusterStateProvider()
123+
.getCollection(DEFAULT_COLLECTION)
124+
.getSlice("shard1")
125+
.getReplicas(r -> r.getType().equals(Replica.Type.PULL));
126+
for (Replica replica : pullReplicas) {
127+
CollectionAdminRequest.deleteReplica(DEFAULT_COLLECTION, "shard1", replica.getName())
128+
.process(cloudClient);
129+
}
130+
}
131+
}
132+
111133
private void doTestHardFail() throws Exception {
112134
log.info("### STARTING doTestHardFail");
113135

0 commit comments

Comments
 (0)