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 2025/03/13 15:02:36 UTC
(solr) branch branch_9x updated: SOLR-17700: Use core operation lock when unloading core (#3260)
This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new cc6ea87d475 SOLR-17700: Use core operation lock when unloading core (#3260)
cc6ea87d475 is described below
commit cc6ea87d4755ee42ec5e742873907eaa368f0cb5
Author: Houston Putman <ho...@apache.org>
AuthorDate: Thu Mar 13 09:07:02 2025 -0500
SOLR-17700: Use core operation lock when unloading core (#3260)
(cherry picked from commit 7725ac3245927ee667c5eed6f1eaaaef184ba3ff)
---
solr/CHANGES.txt | 3 +++
.../src/java/org/apache/solr/core/CoreContainer.java | 19 ++++++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7301c7ffd86..9b2e2e9db84 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -51,6 +51,9 @@ Bug Fixes
current live nodes list is stale. CloudSolrClient now retains the initial configured list of passed URLs as backup
used for fetching cluster state when all live nodes have failed. (Matthew Biscocho via David Smiley, Houston Putman)
+* SOLR-17700: Use Core Operation lock when unloading cores. This fixes errors that occur when a collection deletion and reload
+ occur at the same time. (Houston Putman)
+
Dependency Upgrades
---------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 1f2767302f4..7b0ef6e0ad0 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -1782,7 +1782,9 @@ public class CoreContainer {
(deleteUnknownCores
? " It will be deleted. See SOLR-13396 for more information."
: ""));
- unload(dcore.getName(), deleteUnknownCores, deleteUnknownCores, deleteUnknownCores);
+ // We alreday have an ongoing CoreOp, so do not wait to start another one
+ unloadWithoutCoreOp(
+ dcore.getName(), deleteUnknownCores, deleteUnknownCores, deleteUnknownCores);
throw e;
}
solrCores.removeCoreDescriptor(dcore);
@@ -2158,7 +2160,22 @@ public class CoreContainer {
*/
public void unload(
String name, boolean deleteIndexDir, boolean deleteDataDir, boolean deleteInstanceDir) {
+ try {
+ solrCores.waitAddPendingCoreOps(name);
+ unloadWithoutCoreOp(name, deleteIndexDir, deleteDataDir, deleteInstanceDir);
+ } finally {
+ solrCores.removeFromPendingOps(name);
+ }
+ }
+ /**
+ * This is the actual logic of unloading a core, but does not obtain a lock on the core for the
+ * operation. This method should only be used internally when "unloading" is required within
+ * another core operation. Otherwise, use the public {@link #unload(String, boolean, boolean,
+ * boolean)} method, which will obtain a core operation lock.
+ */
+ private void unloadWithoutCoreOp(
+ String name, boolean deleteIndexDir, boolean deleteDataDir, boolean deleteInstanceDir) {
CoreDescriptor cd = solrCores.getCoreDescriptor(name);
if (name != null) {