Skip to content

Conversation

@Tim-Brooks
Copy link
Contributor

Add a new split recovery source. This recovery type will always be
allocated with a primary term + 1 of the source shard. And will validate
the source primary term has not changed when starting the shard.

@Tim-Brooks Tim-Brooks added >non-issue :Distributed Indexing/Recovery Anything around constructing a new shard, either from a local or a remote source. v9.1.0 labels Mar 13, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Indexing Meta label for Distributed Indexing team label Mar 13, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-indexing (Team:Distributed Indexing)

@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Mar 13, 2025
case PEER -> PeerRecoverySource.INSTANCE;
case SNAPSHOT -> new SnapshotRecoverySource(in);
case LOCAL_SHARDS -> LocalShardsRecoverySource.INSTANCE;
case SPLIT -> SplitRecoverySource.INSTANCE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this recovery type to the top of this class where the other ones are also listed.

}

/**
* peer recovery from a primary shard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: peer -> "reshard split" perhaps ? Can we add a little more description here like this is for reshard when we are increasing number of shards and it is different from the existing split functionality we have ?

return maybeUpdatedState;
}

private static boolean invalidShardSplit(StartedShardEntry startedShardEntry, ProjectId projectId, ClusterState clusterState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, do we have a custom of invalid functions that return false if the state is valid? It seems like a double negative and using valid would be more natural to me, unless that is against custom.

IndexReshardingMetadata reshardingMetadata = indexMetadata.getReshardingMetadata();
assert reshardingMetadata != null;
IndexReshardingState.Split split = reshardingMetadata.getSplit();
int sourceShardId = startedShardEntry.shardId.getId() % split.shardCountBefore();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a function to IndexReshardingState.Split to return the source shard number for a given target? I know it's only modulo but it might be nice to have this kind of logic in one place.

assert indexMetadata != null;
IndexReshardingMetadata reshardingMetadata = indexMetadata.getReshardingMetadata();
assert reshardingMetadata != null;
IndexReshardingState.Split split = reshardingMetadata.getSplit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we could have getSplit return null if reshardingMetadata is null to avoid having to do this two step check.

@Tim-Brooks Tim-Brooks closed this Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Indexing/Recovery Anything around constructing a new shard, either from a local or a remote source. >non-issue serverless-linked Added by automation, don't add manually Team:Distributed Indexing Meta label for Distributed Indexing team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants