Skip to content

Commit

Permalink
Upstream fetch
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Feb 6, 2025
1 parent e82f050 commit 0c6185b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 35 deletions.
2 changes: 1 addition & 1 deletion gradle/run.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ testClusters {
}
setting 'opensearch.experimental.feature.read.write.split.enabled', 'true'
setting 'path.repo', '["/tmp/my-repo"]'
setting 'node.attr.remote_store', 'true'
// setting 'node.attr.remote_store', 'true'
setting 'cluster.remote_store.state.enabled', 'true'
setting 'node.attr.remote_store.segment.repository', 'my-repository'
setting 'node.attr.remote_store.translog.repository', 'my-repository'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@ public ClusterIndexHealth(
}
}
ShardRouting primaryShard = indexShardRoutingTable.primaryShard();
/*if (primaryShard.active()) {
computeActivePrimaryShards++;
}
ClusterHealthStatus shardHealth = ClusterShardHealth.getShardHealth(
primaryShard,
activeShardsPerShardId,
shardRoutingCountPerShardId
);
computeStatus = getIndexHealthStatus(shardHealth, computeStatus);*/

if (primaryShard == null) {
// 3. If there is no primary shard:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.cluster.health;

import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.routing.IndexShardRoutingTable;
import org.opensearch.cluster.routing.RecoverySource;
import org.opensearch.cluster.routing.ShardRouting;
Expand Down Expand Up @@ -230,7 +231,11 @@ public void writeTo(final StreamOutput out) throws IOException {
* Shard health is RED when the primary is not active.
* </p>
*/
public static ClusterHealthStatus getShardHealth(final ShardRouting primaryRouting, final int activeShards, final int totalShards) {
public static ClusterHealthStatus getShardHealth(
final ShardRouting primaryRouting,
final int activeShards,
final int totalShards
) {
// assert primaryRouting != null : "Primary shard routing can't be null";
if (primaryRouting.active()) {
if (activeShards == totalShards) {
Expand All @@ -243,6 +248,7 @@ public static ClusterHealthStatus getShardHealth(final ShardRouting primaryRouti
}
}


/**
* Checks if an inactive primary shard should cause the cluster health to go RED.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,14 +575,8 @@ public static APIBlock readFrom(StreamInput input) throws IOException {
public static final String SETTING_READ_ONLY_ALLOW_DELETE = APIBlock.READ_ONLY_ALLOW_DELETE.settingName();
public static final Setting<Boolean> INDEX_BLOCKS_READ_ONLY_ALLOW_DELETE_SETTING = APIBlock.READ_ONLY_ALLOW_DELETE.setting();


// public static final String SETTING_BLOCKS_SEARCH_ONLY = APIBlock.SEARCH_ONLY.settingName();
// public static final Setting<Boolean> INDEX_BLOCKS_SEARCH_ONLY_SETTING = APIBlock.SEARCH_ONLY.setting();


public static final Setting<Boolean> INDEX_BLOCKS_SEARCH_ONLY_SETTING = APIBlock.SEARCH_ONLY.setting();


public static final String SETTING_VERSION_CREATED = "index.version.created";

public static final Setting<Version> SETTING_INDEX_VERSION_CREATED = Setting.versionSetting(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,13 @@ private void updateRecoveryCounts(final ShardRouting routing, final boolean incr

final int howMany = increment ? 1 : -1;
assert routing.initializing() : "routing must be initializing: " + routing;

boolean isSearchOnly = metadata.index(routing.index()).getSettings().getAsBoolean(IndexMetadata.INDEX_BLOCKS_SEARCH_ONLY_SETTING.getKey(), false);
// TODO: check primary == null || primary.active() after all tests properly add ReplicaAfterPrimaryActiveAllocationDecider
// assert primary == null || primary.assignedToNode() : "shard is initializing but its primary is not assigned to a node";
if (!isSearchOnly) {
assert primary == null || primary.assignedToNode()
: "shard is initializing but its primary is not assigned to a node";
}

// Primary shard routing, excluding the relocating primaries.
if (routing.primary() && (primary == null || primary == routing)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
package org.opensearch.cluster.routing;

import org.opensearch.Version;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource;
import org.opensearch.cluster.routing.RecoverySource.PeerRecoverySource;
import org.opensearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
Expand Down Expand Up @@ -115,8 +116,6 @@ protected ShardRouting(
assert !(state == ShardRoutingState.UNASSIGNED && unassignedInfo == null) : "unassigned shard must be created with meta";
assert (state == ShardRoutingState.UNASSIGNED || state == ShardRoutingState.INITIALIZING) == (recoverySource != null)
: "recovery source only available on unassigned or initializing shard but was " + state;
/*assert recoverySource == null || recoverySource == PeerRecoverySource.INSTANCE || primary || searchOnly
: "replica shards always recover from primary";*/
assert (currentNodeId == null) == (state == ShardRoutingState.UNASSIGNED) : "unassigned shard must not be assigned to a node "
+ this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocat
return allocation.decision(Decision.YES, NAME, "shard is primary and can be allocated");
}
ShardRouting primary = allocation.routingNodes().activePrimary(shardRouting.shardId());
// Added this
/*if (primary == null && !shardRouting.isSearchOnly()) {
return allocation.decision(Decision.NO, NAME, "primary shard for this replica is not yet active");
}*/
if (primary == null) {
boolean indexIsSearchOnly = allocation.metadata()
.getIndexSafe(shardRouting.index())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ public AllocateUnassignedDecision makeAllocationDecision(
return getAllocationDecision(unassignedShard, allocation, nodeShardStores, result, logger);
}

// Added this
protected AllocateUnassignedDecision getAllocationDecision(
ShardRouting unassignedShard,
RoutingAllocation allocation,
Expand All @@ -254,6 +253,7 @@ protected AllocateUnassignedDecision getAllocationDecision(

if (primaryShard == null) {
// Determine if the index is configured for search-only.

boolean isIndexSearchOnly = allocation.metadata()
.getIndexSafe(unassignedShard.index())
.getSettings()
Expand Down Expand Up @@ -284,15 +284,6 @@ protected AllocateUnassignedDecision getAllocationDecision(
return AllocateUnassignedDecision.yes(selectedCandidate, null, new ArrayList<>(), false);
}

/* force methad an allocation using the first available data node.
if (!dataNodes.isEmpty()) {
// forcibly picks the first node
DiscoveryNode forcedCandidate = dataNodes.iterator().next();
logger.info("Forcing allocation of search-only replica {} to node {} because no candidate qualified normally", unassignedShard, forcedCandidate);
return AllocateUnassignedDecision.yes(forcedCandidate, null, new ArrayList<>(), false);
}*/


// If there are no data nodes available, delay allocation.
return AllocateUnassignedDecision.delayed(0L, 0L, null);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public void getCheckpointMetadata(
return;
}

// Added this
if (mdFile == null) {
listener.onResponse(new CheckpointInfoResponse(indexShard.getLatestReplicationCheckpoint(), Collections.emptyMap(), null));
} else {
Expand Down

0 comments on commit 0c6185b

Please sign in to comment.