Skip to content

Commit 2def20a

Browse files
committed
SOLR-17200: Fix false positive race condition in during core loading
1 parent 883fd6d commit 2def20a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

solr/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ Bug Fixes
154154

155155
* SOLR-17113: Correct how `/replication?command=details` describes errors in backup operations. (Przemyslaw Ciezkowski via Christine Poerschke and Jason Gerlowski)
156156

157+
* SOLR-17200: Fix false positive race condition in `/health?requireHealthyCores=true` during core loading (hossman)
158+
157159
Dependency Upgrades
158160
---------------------
159161

solr/core/src/java/org/apache/solr/core/CoreContainer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,10 @@ public long getStatus() {
24532453
return status;
24542454
}
24552455

2456+
public boolean isStatusLoadComplete() {
2457+
return LOAD_COMPLETE == (getStatus() & LOAD_COMPLETE);
2458+
}
2459+
24562460
public boolean hideStackTrace() {
24572461
return cfg.hideStackTraces();
24582462
}

solr/core/src/java/org/apache/solr/handler/admin/HealthCheckHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ private void healthCheckCloudMode(SolrQueryRequest req, SolrQueryResponse rsp) {
149149

150150
// Optionally require that all cores on this node are active if param 'requireHealthyCores=true'
151151
if (req.getParams().getBool(PARAM_REQUIRE_HEALTHY_CORES, false)) {
152+
if (!coreContainer.isStatusLoadComplete()) {
153+
rsp.add(STATUS, FAILURE);
154+
rsp.setException(
155+
new SolrException(
156+
SolrException.ErrorCode.SERVICE_UNAVAILABLE,
157+
"Host Unavailable: Core Loading not complete"));
158+
return;
159+
}
152160
Collection<CloudDescriptor> coreDescriptors =
153-
coreContainer.getCores().stream()
154-
.map(c -> c.getCoreDescriptor().getCloudDescriptor())
161+
coreContainer.getCoreDescriptors().stream()
162+
.map(cd -> cd.getCloudDescriptor())
155163
.collect(Collectors.toList());
156164
long unhealthyCores = findUnhealthyCores(coreDescriptors, clusterState);
157165
if (unhealthyCores > 0) {

0 commit comments

Comments
 (0)