Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelandis committed Oct 2, 2023
1 parent 59db945 commit 921b51a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ public boolean isIndexUpToDate() {

/**
* Optimization to avoid making unnecessary calls when we know the underlying shard state. This call will check that the index exists,
* is discoverable from the alias, is not closed, and determine the type of {@link Availability}.
* is discoverable from the alias, is not closed, and will determine if available based on the {@link Availability} parameter.
* @param availability Check availability for search or write/update/real time get workflows. Write/update/realtime get workflows
* should check for availability of primary shards. Search workflows should check availability of search shards
* (which may or may not also be the primary shards).
* @return
* when checking for search: <code>true</code> if all searchable shards for the security index are available
* when checking for all primary: <code>true</code> if all primary shards for the security index are available
* when checking for primary: <code>true</code> if all primary shards for the security index are available
*/
public boolean isAvailable(Availability availability) {
switch (availability) {
Expand Down Expand Up @@ -176,6 +176,10 @@ public ElasticsearchException getUnavailableReason(Availability availability) {
"at least one primary shard for the index [" + state.concreteIndexName + "] is unavailable"
);
} else if (Availability.SEARCH_SHARDS.equals(availability) && state.indexAvailableForSearch == false) {
// The current behavior is that when primaries are unavailable and replicas can not be promoted then
// any replicas will be marked as unavailable as well. This is applicable in stateless where there index only primaries
// with non-promotable replicas (i.e. search only shards). In the case "at least one search ... is unavailable" is
// a technically correct statement, but it may be unavailable because it is not promotable and the primary is unavailable
return new UnavailableShardsException(
null,
"at least one search shard for the index [" + state.concreteIndexName + "] is unavailable"
Expand Down Expand Up @@ -300,7 +304,7 @@ private Tuple<Boolean, Boolean> checkIndexAvailable(ClusterState state) {
}
if (allPrimaryShards == false || searchShards == false) {
logger.debug(
"Index [{}] is not fully available." + "all primary shards available [{}], search shards available, [{}]",
"Index [{}] is not fully available." + " all primary shards available [{}], search shards available, [{}]",
aliasName,
allPrimaryShards,
searchShards
Expand Down

0 comments on commit 921b51a

Please sign in to comment.