Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17231: Don't try buffering updates when there's no update log. (#3880)

Andrzej Białecki1344194099c2
diff --git a/changelog/unreleased/solr-17231.yml b/changelog/unreleased/solr-17231.yml
new file mode 100644
index 00000000000..4f7ec2cdd08
--- /dev/null
+++ b/changelog/unreleased/solr-17231.yml
@@ -0,0 +1,10 @@
+# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
+title: Don't buffer updates on replicas without update log (e.g. PULL).
+type: fixed # added, changed, fixed, deprecated, removed, dependency_update, security, other
+authors:
+ - name: Andrzej Bialecki
+links:
+ - name: SOLR-17231
+ url: https://issues.apache.org/jira/browse/SOLR-17231
+issues:
+ - 17231
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 5c719e26745..fadde05cf70 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -85,6 +85,7 @@ import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.ResourceLoader;
import org.apache.solr.client.solrj.impl.JavaBinResponseParser;
+import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.RecoveryStrategy;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException;
@@ -1269,10 +1270,12 @@ public class SolrCore implements SolrInfoBean, Closeable {
// ZK pre-register would have already happened so we read slice properties now
final ClusterState clusterState = coreContainer.getZkController().getClusterState();
+ final CloudDescriptor cloudDescriptor = coreDescriptor.getCloudDescriptor();
final DocCollection collection =
- clusterState.getCollection(coreDescriptor.getCloudDescriptor().getCollectionName());
- final Slice slice = collection.getSlice(coreDescriptor.getCloudDescriptor().getShardId());
- if (slice.getState() == Slice.State.CONSTRUCTION) {
+ clusterState.getCollection(cloudDescriptor.getCollectionName());
+ final Slice slice = collection.getSlice(cloudDescriptor.getShardId());
+ if (slice.getState() == Slice.State.CONSTRUCTION
+ && getUpdateHandler().getUpdateLog() != null) {
// set update log to buffer before publishing the core
getUpdateHandler().getUpdateLog().bufferUpdates();
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java
index ba349ad9663..d96bca09215 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java
@@ -430,6 +430,28 @@ public class TestPullReplica extends SolrCloudTestCase {
doTestNoLeader(false);
}
+ @Test
+ public void testNoBufferingInPullIfConstructing() throws Exception {
+ CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1, 0, 0)
+ .process(cluster.getSolrClient());
+ waitForState("Replica not added", collectionName, activeReplicaCount(1, 0, 0));
+
+ setSliceState(collectionName, "shard1", Slice.State.CONSTRUCTION);
+
+ CollectionAdminRequest.addReplicaToShard(collectionName, "shard1", Replica.Type.PULL)
+ .process(cluster.getSolrClient());
+ waitForState("Replica not added", collectionName, activeReplicaCount(1, 0, 1));
+ }
+
+ private void setSliceState(String collectionName, String shardId, Slice.State state)
+ throws Exception {
+ ShardTestUtil.setSliceState(cluster, collectionName, shardId, state);
+ waitForState(
+ "Expected shard " + shardId + " to be in state " + state,
+ collectionName,
+ c -> c.getSlice(shardId).getState() == state);
+ }
+
@Ignore("Ignore until I figure out a way to reliably record state transitions")
public void testPullReplicaStates() throws Exception {
// Validate that pull replicas go through the correct states when starting, stopping,