Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Abort federation requests if the client disconnects early #7930

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jul 21, 2020

For inbound federation requests, if a given remote server makes too many
requests at once, we start stacking them up rather than processing them
immediatedly.

However, that means that there is a fair chance that the requesting server will
disconnect before we start processing the request. In that case, if it was a
read-only request (ie, a GET request), there is absolutely no point in
building a response (and some requests are quite expensive to handle).

Even in the case of a POST request, one of two things will happen:

  • Most likely, the requesting server will retry the request and we'll get the
    information anyway.

  • Even if it doesn't, the requesting server has to assume that we didn't get
    the memo, and act accordingly.

In short, we're better off aborting the request at this point rather than
ploughing on with what might be a quite expensive request.

For inbound federation requests, if a given remote server makes too many
requests at once, we start stacking them up rather than processing them
immediatedly.

However, that means that there is a fair chance that the requesting server will
disconnect before we start processing the request. In that case, if it was a
read-only request (ie, a GET request), there is absolutely no point in
building a response (and some requests are quite expensive to handle).

Even in the case of a POST request, one of two things will happen:

 * Most likely, the requesting server will retry the request and we'll get the
   information anyway.

 * Even if it doesn't, the requesting server has to assume that we didn't get
   the memo, and act accordingly.

In short, we're better off aborting the request at this point rather than
ploughing on with what might be a quite expensive request.
@richvdh richvdh requested a review from a team July 21, 2020 23:50
"client disconnected before we started processing "
"request"
)
return -1, None
Copy link
Contributor

Choose a reason for hiding this comment

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

-1 just because this is a garbage response and it doesn't really matter?

This seems similar to #7927 where 200, {} was returned. Why the difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

errr good question.

None ensures that we don't call respond_with_json.

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 be using it in the other place too then? 😄 Either way I think this is OK!

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, probably. I think this this the better way. we could clean up #7927 for consistency but I don't think it's a big deal really.

@richvdh richvdh merged commit 4876af0 into develop Jul 23, 2020
@richvdh richvdh deleted the rav/abort_disconnected_fed_requests branch July 23, 2020 15:52
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit '4876af06d':
  Abort federation requests if the client disconnects early (#7930)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants