Skip to content

Commit

Permalink
SOLR-16753: Fix PRS state update for splitShard (#1787)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0a2bda2)
  • Loading branch information
HoustonPutman committed Jul 17, 2023
1 parent 5c83a92 commit 42a15fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,15 @@ private ZkWriteCommand updateState(
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 {
Expand All @@ -442,7 +445,7 @@ private ZkWriteCommand updateState(
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 {}",
Expand All @@ -462,6 +465,7 @@ private boolean persistStateJson(Replica newReplica, Replica oldReplica, DocColl
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))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
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());

Expand Down

0 comments on commit 42a15fd

Please sign in to comment.