nick-boss-tech commented on code in PR #4959:
URL: https://github.com/apache/solr/pull/4959#discussion_r4136657636


##########
solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java:
##########
@@ -1053,6 +1014,46 @@ private void cleanupAfterFailure(
     }
   }
 
+  /**
+   * Slice-state rollback for a failed split, or {@code null} if the committed 
switch-over must not
+   * be undone. Always includes parent=ACTIVE so a stale snapshot cannot skip 
the restore.
+   */
+  static Map<String, Object> buildCleanupShardStateUpdates(
+      DocCollection coll, String parentShard, List<String> subSlices, 
Set<String> offlineSlices) {
+    // If parent is inactive and all sub shards are active, then rolling back
+    // to make the parent active again will cause data loss.
+    if (coll.getSlice(parentShard).getState() == Slice.State.INACTIVE) {
+      boolean allSubSlicesActive = true;
+      for (String sub : subSlices) {
+        if (coll.getSlice(sub).getState() != Slice.State.ACTIVE) {
+          allSubSlicesActive = false;
+          break;
+        }
+      }
+      if (allSubSlicesActive) {
+        return null;
+      }
+    }
+
+    // set already created sub shards states to CONSTRUCTION - this prevents 
them
+    // from entering into RECOVERY or ACTIVE (SOLR-9455)
+    final Map<String, Object> propMap = new HashMap<>();
+    propMap.put(Overseer.QUEUE_OPERATION, 
OverseerAction.UPDATESHARDSTATE.toLower());
+    propMap.put(ZkStateReader.COLLECTION_PROP, coll.getName());
+    for (Slice s : coll.getSlices()) {
+      if (!subSlices.contains(s.getName())) {
+        continue;
+      }
+      propMap.put(s.getName(), Slice.State.CONSTRUCTION.toString());
+    }
+    // Always pin parent ACTIVE; a stale snapshot can miss an in-flight 
INACTIVE switch.
+    propMap.put(parentShard, Slice.State.ACTIVE.toString());
+    for (String sliceName : offlineSlices) {

Review Comment:
   Historical and current source tracing found no writer or legitimate 
population trigger for `offlineSlices`. `SplitShardCmd` changes only the 
requested parent and its generated child slices, so the dead `offlineSlices` 
plumbing was removed instead of populating it. The existing cleanup tests pass, 
and parent restoration, child reset, and the completed-switch guard are 
retained.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to