Skip to content

Commit 1344194

Browse files
authored
SOLR-17231: Don't try buffering updates when there's no update log. (#3880)
1 parent 6a9e33b commit 1344194

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
2+
title: Don't buffer updates on replicas without update log (e.g. PULL).
3+
type: fixed # added, changed, fixed, deprecated, removed, dependency_update, security, other
4+
authors:
5+
- name: Andrzej Bialecki
6+
links:
7+
- name: SOLR-17231
8+
url: https://issues.apache.org/jira/browse/SOLR-17231
9+
issues:
10+
- 17231

solr/core/src/java/org/apache/solr/core/SolrCore.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import org.apache.lucene.store.LockObtainFailedException;
8686
import org.apache.lucene.util.ResourceLoader;
8787
import org.apache.solr.client.solrj.impl.JavaBinResponseParser;
88+
import org.apache.solr.cloud.CloudDescriptor;
8889
import org.apache.solr.cloud.RecoveryStrategy;
8990
import org.apache.solr.cloud.ZkSolrResourceLoader;
9091
import org.apache.solr.common.SolrException;
@@ -1269,10 +1270,12 @@ protected void bufferUpdatesIfConstructing(CoreDescriptor coreDescriptor) {
12691270

12701271
// ZK pre-register would have already happened so we read slice properties now
12711272
final ClusterState clusterState = coreContainer.getZkController().getClusterState();
1273+
final CloudDescriptor cloudDescriptor = coreDescriptor.getCloudDescriptor();
12721274
final DocCollection collection =
1273-
clusterState.getCollection(coreDescriptor.getCloudDescriptor().getCollectionName());
1274-
final Slice slice = collection.getSlice(coreDescriptor.getCloudDescriptor().getShardId());
1275-
if (slice.getState() == Slice.State.CONSTRUCTION) {
1275+
clusterState.getCollection(cloudDescriptor.getCollectionName());
1276+
final Slice slice = collection.getSlice(cloudDescriptor.getShardId());
1277+
if (slice.getState() == Slice.State.CONSTRUCTION
1278+
&& getUpdateHandler().getUpdateLog() != null) {
12761279
// set update log to buffer before publishing the core
12771280
getUpdateHandler().getUpdateLog().bufferUpdates();
12781281
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,28 @@ public void testKillLeader() throws Exception {
430430
doTestNoLeader(false);
431431
}
432432

433+
@Test
434+
public void testNoBufferingInPullIfConstructing() throws Exception {
435+
CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1, 0, 0)
436+
.process(cluster.getSolrClient());
437+
waitForState("Replica not added", collectionName, activeReplicaCount(1, 0, 0));
438+
439+
setSliceState(collectionName, "shard1", Slice.State.CONSTRUCTION);
440+
441+
CollectionAdminRequest.addReplicaToShard(collectionName, "shard1", Replica.Type.PULL)
442+
.process(cluster.getSolrClient());
443+
waitForState("Replica not added", collectionName, activeReplicaCount(1, 0, 1));
444+
}
445+
446+
private void setSliceState(String collectionName, String shardId, Slice.State state)
447+
throws Exception {
448+
ShardTestUtil.setSliceState(cluster, collectionName, shardId, state);
449+
waitForState(
450+
"Expected shard " + shardId + " to be in state " + state,
451+
collectionName,
452+
c -> c.getSlice(shardId).getState() == state);
453+
}
454+
433455
@Ignore("Ignore until I figure out a way to reliably record state transitions")
434456
public void testPullReplicaStates() throws Exception {
435457
// Validate that pull replicas go through the correct states when starting, stopping,

0 commit comments

Comments
 (0)