You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2023/07/17 20:25:56 UTC
[solr] branch main updated: SOLR-16753: Fix PRS state update for splitShard (#1787)
This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 0a2bda206a0 SOLR-16753: Fix PRS state update for splitShard (#1787)
0a2bda206a0 is described below
commit 0a2bda206a0bee4668cbdf3e6410202113abe784
Author: Houston Putman <ho...@apache.org>
AuthorDate: Mon Jul 17 16:25:50 2023 -0400
SOLR-16753: Fix PRS state update for splitShard (#1787)
---
solr/CHANGES.txt | 2 ++
.../src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java | 6 +++++-
.../src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java | 5 +++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 268cc31326e..79a86e82314 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -326,6 +326,8 @@ Bug Fixes
* SOLR-16877: BackupManager now allows ConfigSet "files" to be empty, which previously caused NPEs. (Paul Blanchaert via Houston Putman)
+* SOLR-16753: PRS state is now always updated at the end of a splitShard. (Houston Putman, hossman)
+
Dependency Upgrades
---------------------
* PR#1494: Upgrade forbiddenapis to 3.5 (Uwe Schindler)
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
index 96a3a7538a7..3b06bbe6df8 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
@@ -421,12 +421,15 @@ public class ReplicaMutator {
Map<String, Object> sliceProps = null;
Map<String, Replica> replicas;
+ boolean sliceChanged = true;
if (slice != null) {
+ Slice.State originalState = slice.getState();
collection =
checkAndCompleteShardSplit(prevState, collection, coreNodeName, sliceName, replica);
// get the current slice again because it may have been updated due to
// checkAndCompleteShardSplit method
slice = collection.getSlice(sliceName);
+ sliceChanged = originalState != slice.getState();
sliceProps = slice.getProperties();
replicas = slice.getReplicasCopy();
} else {
@@ -442,7 +445,7 @@ public class ReplicaMutator {
DocCollection newCollection = CollectionMutator.updateSlice(collectionName, collection, slice);
log.debug("Collection is now: {}", newCollection);
if (collection.isPerReplicaState() && oldReplica != null) {
- if (!persistStateJson(replica, oldReplica, collection)) {
+ if (!sliceChanged && !persistStateJson(replica, oldReplica, collection)) {
if (log.isDebugEnabled()) {
log.debug(
"state.json is not persisted slice/replica : {}/{} \n , old : {}, \n new {}",
@@ -462,6 +465,7 @@ public class ReplicaMutator {
if (!Objects.equals(newReplica.getBaseUrl(), oldReplica.getBaseUrl())) return true;
if (!Objects.equals(newReplica.getCoreName(), oldReplica.getCoreName())) return true;
if (!Objects.equals(newReplica.getNodeName(), oldReplica.getNodeName())) return true;
+ if (!Objects.equals(newReplica.getState(), oldReplica.getState())) return true;
if (!Objects.equals(
newReplica.getProperties().get(ZkStateReader.FORCE_SET_STATE_PROP),
oldReplica.getProperties().get(ZkStateReader.FORCE_SET_STATE_PROP))) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java b/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java
index c30bfae328c..d698758cd06 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java
@@ -24,13 +24,14 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.core.NodeRoles;
+import org.apache.solr.util.LogLevel;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@Ignore("SOLR-16753")
+@LogLevel(
+ "org.apache.solr.cloud.overseer=DEBUG;org.apache.solr.cloud=DEBUG;org.apache.solr.cloud.api.collections=DEBUG")
public class SplitShardWithNodeRoleTest extends SolrCloudTestCase {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());