Skip to content

Conversation

@dnhatn
Copy link
Member

@dnhatn dnhatn commented Nov 24, 2020

Few things that prevent us from supporting cross-clusters tasks cancellation:

  1. A child task gets canceled if a node with the parent task leaves the cluster. This doesn't hold for a cross-clusters task as the parent task does not belong to the remote cluster. This issue was resolved in Cancel task and descendants on channel disconnects #56620, where we cancel child tasks on disconnect instead.

  2. Ban action isn't registered on proxy nodes

  3. Banned parent markers are removed when a node with the parent task leaves the cluster. This issue is similar to the first issue.

This commit tries to address the third issue by periodically (every 5 minutes) sending heartbeats for banned parent markers and removing markers that haven't received heartbeats for some time (30 minutes).

This commit tries to address the third issue by sending a ban for each outstanding child connection and removing it when all associated connections disconnect.

@dnhatn dnhatn added >enhancement :Distributed Coordination/Task Management Issues for anything around the Tasks API - both persistent and node level. v8.0.0 v7.11.0 labels Nov 24, 2020
@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Nov 24, 2020
@elasticmachine
Copy link
Collaborator

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

@dnhatn
Copy link
Member Author

dnhatn commented Nov 24, 2020

@DaveCTurner I looked into your proposal to remove a ban once all associated child connections are disconnected. However, it isn't watertight as we can remove a ban before an in-flight child task start. Any suggestions are welcomed.

@DaveCTurner
Copy link
Contributor

DaveCTurner commented Nov 25, 2020

However, it isn't watertight as we can remove a ban before an in-flight child task start. Any suggestions are welcomed.

Hmm wouldn't that mean the child task is going to respond on a connection that was closed before the task even started? If so we shouldn't even start the task.

@dnhatn
Copy link
Member Author

dnhatn commented Nov 25, 2020

I should have been more clear. We do not prevent a child task from starting in this scenario:

  1. The parent task sends message m1 to start a child task t1 on node-1 using connection c1
  2. The parent task also sends message m2 to start a child task t2 on node-1 using connection c2
  3. Message m1 arrives, and node-1 starts child task t1
  4. The parent task is canceled
  5. We send a ban message b1 to node-1 (to cancel or prevent t1/t2 from starting)
  6. If the connection c1 is disconnected and we remove the ban b1, then node-1 will start child task t2 when the message m2 arrives

@DaveCTurner
Copy link
Contributor

I see. Could we indicate in the ban message that there are already in-flight tasks on connections c1 and c2, so it doesn't get removed while c2 is still open?

@DaveCTurner
Copy link
Contributor

On reflection that sounds hard, we have no way to refer to a specific connection that the other end can understand, except of course sending the ban over every relevant connection.

@dnhatn
Copy link
Member Author

dnhatn commented Nov 25, 2020

Another issue is proxy connections. A proxy connection consists of two connections: the source node to the proxy node and the proxy node to the target node. While the former will never change, the latter can change anytime. I think we can't use the connection info to remove ban markers.

@DaveCTurner
Copy link
Contributor

Right, that was what I meant earlier about having the proxy also proxy a disconnect event. We can't describe a specific set of connections to a remote cluster, but we can say "the connection on which this message was received".

This reverts commit 50ed116.

Revert "Periodically send heartbeat for banned parent marker"

This reverts commit 1e26011.
@dnhatn dnhatn changed the title Periodically send heartbeat for banned parent marker Send parent ban per outstanding child connection Dec 1, 2020
@dnhatn dnhatn changed the title Send parent ban per outstanding child connection Send ban parent per outstanding child connection Dec 1, 2020
@dnhatn
Copy link
Member Author

dnhatn commented Dec 1, 2020

@DaveCTurner I implemented a prototype that does not require heartbeats for the ban markers. In the prototype, we send a ban for each outstanding child connection and remove bans when all associated connections of that ban disconnect.

I've updated this PR to send bans per child connection and will open a follow-up to associate connections to bans. This PR is ready for review again. Can you please take another look? Thank you!

@dnhatn
Copy link
Member Author

dnhatn commented Dec 3, 2020

I also included (but reverted from this PR) the commit 143620d that tracks bans for each channel and removes them when their associated channels are closed.

Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Hmm, I think this still isn't quite watertight, because a Connection is a bundle of channels so messages to a single Connection are not fully ordered. I think it's possible that we could send a task T on one channel that takes a very long time to arrive, then on a different channel send the ban and receive a response, then clear the ban and receive a response, and only then does task T arrive at the target.

Edit: I see that I caused this confusion: I said "connection" in the earlier discussion. I meant TCP connection, i.e. channel.

@dnhatn
Copy link
Member Author

dnhatn commented Dec 7, 2020

@DaveCTurner Thanks for looking. That's a good point. I think we can make it tighter by sending a ban for every pair of Connection and TransportRequestOptions.Type, which is used to pick a TCP channel. WDYT?

@dnhatn dnhatn requested review from jimczi and removed request for henningandersen December 7, 2020 18:18
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

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

Ok thanks for confirming, this LGTM then. Neatly done, I like this change 😄

@dnhatn
Copy link
Member Author

dnhatn commented Dec 8, 2020

@DaveCTurner Thanks so much for reviewing and suggesting this direction :)

@dnhatn
Copy link
Member Author

dnhatn commented Dec 8, 2020

@elasticmachine update branch

@dnhatn dnhatn merged commit 303b3c4 into elastic:master Dec 8, 2020
@dnhatn dnhatn deleted the ban-task-heartbeat branch December 8, 2020 16:55
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Dec 12, 2020
This commit sends a parent-task ban for each connection so that we can
reply on channel disconnect instead of node leave events to remove bans.
dnhatn added a commit that referenced this pull request Dec 12, 2020
This commit sends a parent-task ban for each connection so that we can
reply on channel disconnect instead of node leave events to remove bans.

Backport #65443
dnhatn added a commit that referenced this pull request Dec 16, 2020
Like #56620, this change relies on channel disconnect instead of node 
leave events to remove parent-task ban markers.

Relates #65443
Relates #56620
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Dec 16, 2020
Like elastic#56620, this change relies on channel disconnect instead of node
leave events to remove parent-task ban markers.

Relates elastic#65443
Relates elastic#56620
dnhatn added a commit that referenced this pull request Dec 17, 2020
Like #56620, this change relies on channel disconnect instead of node
leave events to remove parent-task ban markers.

Relates #65443
Relates #56620
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Jun 13, 2021
If a `NodeDisconnectedException` happens when sending a ban for a task
then today we log a message at `INFO` or `WARN` indicating that the ban
failed, but we don't indicate why. The message also uses a default
`toString()` for an inner class which is unhelpful.

Ban failures during disconnections are benign and somewhat expected, and
task cancellation respects disconnections anyway (elastic#65443). There's not
much the user can do about these messages either, and they can be
confusing and draw attention away from the real problem.

With this commit we log the failure messages at `DEBUG` on
disconnections, and include the exception details. We also include the
exception message for other kinds of failures, and we fix up a few cases
where a useless default `toString()` implementation was used in log
messages.

Slightly relates elastic#72968 in that these messages tend to obscure a
connectivity issue.
DaveCTurner added a commit that referenced this pull request Jun 14, 2021
If a `NodeDisconnectedException` happens when sending a ban for a task
then today we log a message at `INFO` or `WARN` indicating that the ban
failed, but we don't indicate why. The message also uses a default
`toString()` for an inner class which is unhelpful.

Ban failures during disconnections are benign and somewhat expected, and
task cancellation respects disconnections anyway (#65443). There's not
much the user can do about these messages either, and they can be
confusing and draw attention away from the real problem.

With this commit we log the failure messages at `DEBUG` on
disconnections, and include the exception details. We also include the
exception message for other kinds of failures, and we fix up a few cases
where a useless default `toString()` implementation was used in log
messages.

Slightly relates #72968 in that these messages tend to obscure a
connectivity issue.
DaveCTurner added a commit that referenced this pull request Jun 14, 2021
If a `NodeDisconnectedException` happens when sending a ban for a task
then today we log a message at `INFO` or `WARN` indicating that the ban
failed, but we don't indicate why. The message also uses a default
`toString()` for an inner class which is unhelpful.

Ban failures during disconnections are benign and somewhat expected, and
task cancellation respects disconnections anyway (#65443). There's not
much the user can do about these messages either, and they can be
confusing and draw attention away from the real problem.

With this commit we log the failure messages at `DEBUG` on
disconnections, and include the exception details. We also include the
exception message for other kinds of failures, and we fix up a few cases
where a useless default `toString()` implementation was used in log
messages.

Slightly relates #72968 in that these messages tend to obscure a
connectivity issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed Coordination/Task Management Issues for anything around the Tasks API - both persistent and node level. >enhancement Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. v7.11.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants