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 2024/03/27 19:45:03 UTC
(solr) branch main updated: SOLR-17200: Fix false positive race condition in during core loading
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 2def20abfe8 SOLR-17200: Fix false positive race condition in during core loading
2def20abfe8 is described below
commit 2def20abfe85d77f1fcd42a24d01c77b9ee07b82
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Wed Mar 27 14:44:51 2024 -0500
SOLR-17200: Fix false positive race condition in during core loading
---
solr/CHANGES.txt | 2 ++
solr/core/src/java/org/apache/solr/core/CoreContainer.java | 4 ++++
.../org/apache/solr/handler/admin/HealthCheckHandler.java | 12 ++++++++++--
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index aa61877e882..7001eb0232b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -154,6 +154,8 @@ Bug Fixes
* SOLR-17113: Correct how `/replication?command=details` describes errors in backup operations. (Przemyslaw Ciezkowski via Christine Poerschke and Jason Gerlowski)
+* SOLR-17200: Fix false positive race condition in `/health?requireHealthyCores=true` during core loading (hossman)
+
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 3d66853a781..8f3ee608011 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -2453,6 +2453,10 @@ public class CoreContainer {
return status;
}
+ public boolean isStatusLoadComplete() {
+ return LOAD_COMPLETE == (getStatus() & LOAD_COMPLETE);
+ }
+
public boolean hideStackTrace() {
return cfg.hideStackTraces();
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java
index 3f5c8442b47..a3724aa626c 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java
@@ -149,9 +149,17 @@ public class HealthCheckHandler extends RequestHandlerBase {
// Optionally require that all cores on this node are active if param 'requireHealthyCores=true'
if (req.getParams().getBool(PARAM_REQUIRE_HEALTHY_CORES, false)) {
+ if (!coreContainer.isStatusLoadComplete()) {
+ rsp.add(STATUS, FAILURE);
+ rsp.setException(
+ new SolrException(
+ SolrException.ErrorCode.SERVICE_UNAVAILABLE,
+ "Host Unavailable: Core Loading not complete"));
+ return;
+ }
Collection<CloudDescriptor> coreDescriptors =
- coreContainer.getCores().stream()
- .map(c -> c.getCoreDescriptor().getCloudDescriptor())
+ coreContainer.getCoreDescriptors().stream()
+ .map(cd -> cd.getCloudDescriptor())
.collect(Collectors.toList());
long unhealthyCores = findUnhealthyCores(coreDescriptors, clusterState);
if (unhealthyCores > 0) {