Skip to content

Utility to broadcast to unpromotable shards #93552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kingherc
Copy link
Contributor

@kingherc kingherc commented Feb 7, 2023

Introduces:

  • IndexShardRoutingTable now lists unpromotable assigned shards.
  • New utility TransportActions#broadcastToUnpromotableShards().
  • New hook in ReplicationOperation for custom logic when the primary operation completes.
  • Refresh action now uses the new hook to broadcast the unpromotable refresh action to all unpromotable shards.

Fixes ES-5454

Introduces:

* IndexShardRoutingTable now lists unpromotable assigned shards.
* New utility TransportActions#broadcastToUnpromotableShards().
* New hook in ReplicationOperation for custom logic when the
  primary operation completes.
* Refresh action now uses the new hook to broadcast the
  unpromotable refresh action to all unpromotable shards.

Fixes ES-5454
@kingherc kingherc added >feature :Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.7.0 labels Feb 7, 2023
@kingherc kingherc requested a review from DaveCTurner February 7, 2023 11:43
@kingherc kingherc self-assigned this Feb 7, 2023
@elasticsearchmachine
Copy link
Collaborator

Hi @kingherc, I've created a changelog YAML for you.

@kingherc
Copy link
Contributor Author

kingherc commented Feb 7, 2023

@DaveCTurner take a look at this new PR, which uses a simple hook similar to the one you proposed in ReplicationOperation. Also extracted the utility function to broadcast to unpromotable shards.

@kingherc kingherc marked this pull request as ready for review February 7, 2023 12:43
@kingherc kingherc requested a review from tlrx February 7, 2023 12:43
@elasticsearchmachine
Copy link
Collaborator

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

@kingherc kingherc requested a review from idegtiarenko February 7, 2023 14:49
TransportService transportService,
String responseHandlerExecutor,
ActionListener<Void> listener
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am new to this area, but I wonder if this should be a static utility?
It seems like there is a pattern of making abstract actions like TransportBroadcastAction.
May be @tlrx or @DaveCTurner could advice on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Written like this, I would agree. However, I think the caller should be able to pass in an IndexShardRoutingTable rather than having to read the cluster state from the ClusterService, because the state in the ClusterService may differ from the one that the caller expects. With that change, it's a bit harder to express this as another kind of abstract action - the IndexShardRoutingTable would have to be carried in the request itself, which must be an ActionRequest, and hence Writeable. Maybe that's ok? It still seems a bit weird cos we never actually want to send such a request over the wire.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also do we want to test this logic or it is okay that it is implicitly covered by other tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @idegtiarenko and @DaveCTurner ! Another reason we cannot do an abstract action is that the Refresh action already inherits TransportReplicationAction. I tried that in the previous days with PRs #93518 and #93532 but after discussing with @DaveCTurner , the conclusion was to not make the replication action more complex. And instead provide a simple hook (this PR) that they can do custom stuff, such as broadcasting to unpromotable shards. Since we precluded extending TransportReplicationAction, we cannot make an abstract action as Refresh cannot inherit two classes. So either Refresh would need to hardcode the broadcasting logic, or we refactor it in a utility function like this that can be re-used across the board (e.g., by Stateless actions).

should be able to pass in an IndexShardRoutingTable rather than having to read the cluster state from the ClusterService

@DaveCTurner , I can make it pass IndexShardRoutingTable. But I believe I would still need the ClusterService to get the cluster state to convert shards' node IDs to DiscoveryNodes, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also do we want to test this logic or it is okay that it is implicitly covered by other tests?

For the moment, this is tested in org.elasticsearch.cluster.routing.ShardRoutingRoleIT#testRefreshOfUnpromotableShards indirectly. That is the only IT file so far in ES that tests unpromotable shards. I will see if/how I can make a generic test for the new utility function there.

Copy link
Contributor

Choose a reason for hiding this comment

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

we cannot make an abstract action as Refresh cannot inherit two classes.

That's ok tho, the unpromotable bit would be a separate action.

But I believe I would still need the ClusterService to get the cluster state to convert shards' node IDs to DiscoveryNodes, right?

Ah ok you'd need to accept the DiscoveryNodes too.

Maybe that's ok?

I've thought about this for a bit and decided that yes this is ok and indeed I prefer it 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've thought about this for a bit and decided that yes this is ok and indeed I prefer it

Trying to connect the dots, you mean we can make a new abstract action that underneaths broadcasts it to unpromotable shards, and Refresh does not inherit it, but rather executes it? I guess that will work and is in line with @idegtiarenko 's comment. Let me see if/how I can make this.

BTW, we'd still need the hook of this PR for the custom logic so that Refresh actually shoots the new abstract action.

Copy link
Contributor

Choose a reason for hiding this comment

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

Refresh does not inherit it, but rather executes it

Yep.

we'd still need the hook of this PR for the custom logic

Yep.

I will see if/how I can make a generic test for the new utility function there.

I would prefer to have unit tests covering this logic. It is a little awkward to set everything up for such a test, but it's well worth it. See e.g. TransportNodesActionTests or TransportBroadcastByNodeActionTests for some test suites of similar things.

@arteam arteam self-requested a review February 8, 2023 14:34
@kingherc
Copy link
Contributor Author

kingherc commented Feb 8, 2023

Closing in favor of new PR #93600

@kingherc kingherc closed this Feb 8, 2023
@kingherc kingherc deleted the feature/ES-5454-utility-to-forward-unpromotables branch February 8, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Indexing/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. >feature Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants