This is an automated email from the ASF dual-hosted git repository. dsmiley pushed a commit to branch branch_10x in repository https://gitbox.apache.org/repos/asf/solr.git
commit aa4d77520bf31eb34de86c7e7235a2ef1ff0bb60 Author: Andrzej BiaĆecki <[email protected]> AuthorDate: Mon Nov 24 12:27:52 2025 +0100 SOLR-17231: Don't try buffering updates when there's no update log. (#3880) (cherry picked from commit 1344194099c29ff2391266c77682198a3c6f4468) --- changelog/unreleased/solr-17231.yml | 10 ++++++++++ .../src/java/org/apache/solr/core/SolrCore.java | 9 ++++++--- .../org/apache/solr/cloud/TestPullReplica.java | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) 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 2d57377b5a2..7e9eaeb01b2 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -83,6 +83,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.response.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; @@ -1239,10 +1240,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 213b487459f..c1bece3037d 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java @@ -429,6 +429,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,
