serhiy-bzhezytskyy commented on code in PR #4764:
URL: https://github.com/apache/solr/pull/4764#discussion_r3819708186


##########
solr/core/src/java/org/apache/solr/core/CoreContainer.java:
##########
@@ -1382,13 +1382,12 @@ public void shutdown() {
   }
 
   public void cancelCoreRecoveries() {
-
-    List<SolrCore> cores = solrCores.getCores();
-
     // we must cancel without holding the cores sync
     // make sure we wait for any recoveries to stop
-    for (SolrCore core : cores) {
-      try {
+    for (String coreName : solrCores.getLoadedCoreNames()) {
+      // getCoreFromAnyList, not getCore: never loads, safe during shutdown
+      try (SolrCore core = solrCores.getCoreFromAnyList(coreName, true)) {

Review Comment:
   Went further and wrote a concurrency stress test for this exact concern 
(production, not just the single-threaded mechanism) -- 3 threads 
acquiring/releasing via `getCoreFromAnyList(name, true)` while a 4th 
concurrently unloads/reloads the same core. 0 failures across ~730k 
acquisitions in 4 runs. Added as 
`TestCoreContainer.testGetCoreFromAnyListSafeUnderConcurrentUnload`, pushed.
   
   AI-assisted (Claude Sonnet 5)



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