Copilot commented on code in PR #5371:
URL: https://github.com/apache/solr/pull/5371#discussion_r4650697589


##########
solr/core/src/java/org/apache/solr/pkg/PackageStore.java:
##########
@@ -336,11 +340,20 @@ void deleteVersion(String packageName, String version) {
                 }
                 versions.remove(idxToRemove);
                 packages.znodeVersion = stat.getVersion() + 1;
+                finalState[0] = packages;
                 return Utils.toJSON(packages);
               });
     } catch (KeeperException | InterruptedException e) {
+      finalState[0] = null;
       handleZkErr(e);
     }
+
+    if (finalState[0] == null) {
+      return null;
+    }
+    pkgs = finalState[0];
+    packageLoader.refreshPackageConf();

Review Comment:
   This local snapshot is published without coordinating with the other 
mutation path. Two concurrent requests can commit versions v1 and v2 in 
ZooKeeper, then the v2 request can assign `pkgs` first and the slower v1 
request can assign its older `finalState[0]` afterward. The handling node can 
therefore immediately regress to a stale state (including resurrecting a 
version that the delete removed). Serialize the local publish with package 
mutations, or install the snapshot only when its znode version is still at 
least the current one, with proper cross-thread visibility.



##########
solr/core/src/java/org/apache/solr/pkg/ClusterPackage.java:
##########
@@ -109,7 +109,10 @@ public SolrJerseyResponse deletePackageVersion(String 
packageName, String versio
     final var response = new SolrJerseyResponse();
     PackageStore packageStore = 
coreContainer.getPackageLoader().getPackageStore();
 
-    packageStore.deleteVersion(packageName, version);
+    Integer newVersion = packageStore.deleteVersion(packageName, version);
+    if (newVersion != null) {
+      notifyAllNodesToSync(newVersion);

Review Comment:
   The new inter-node synchronization path is not directly covered: the 
one-node API test only checks the handling node, while the multi-node package 
test uses eventual retries that would also pass if this notification were 
removed and the ZooKeeper watcher eventually propagated the delete. Add an 
assertion that a non-handling node observes the deletion immediately (or before 
watcher propagation) so regressions in this call are caught.



-- 
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