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

Apply join rate limiter outside the lineariser #16441

Merged
merged 5 commits into from
Oct 6, 2023
Merged

Conversation

DMRobertson
Copy link
Contributor

I came across this logic; got confused, then tried to tidy it up. I found this much easier to reason about---doing the rate limit check up front.

At some point, someone should draw out a flowchart of the various membership-updating functions here. It's very confusing.

Commitwise reviewable.

@DMRobertson DMRobertson marked this pull request as ready for review October 6, 2023 17:15
@DMRobertson DMRobertson requested a review from a team as a code owner October 6, 2023 17:15
Copy link
Member

@clokep clokep left a comment

Choose a reason for hiding this comment

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

Good w/ me if tests look good.

Comment on lines +618 to +624
if current_membership != Membership.JOIN:
await self._join_rate_limiter_local.ratelimit(requester)
await self._join_rate_per_room_limiter.ratelimit(
requester, key=room_id, update=False
)
elif action == Membership.INVITE:
await self.ratelimit_invite(requester, room_id, target.to_string())
Copy link
Member

Choose a reason for hiding this comment

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

Nice consolidation here. 👍

I wondered why we couldn't remove ratelimit from other spots, but we pass it into handle_new_client_event.

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 had the same thought (sorry, should have left a comment to this effect), and decided that I was too scared to see if the ratelimiting logic was further disentangleable.

Copy link
Member

Choose a reason for hiding this comment

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

Completely fair, I think this is a solid improvement.

@DMRobertson DMRobertson enabled auto-merge (squash) October 6, 2023 17:29
@DMRobertson DMRobertson merged commit 1f10c20 into develop Oct 6, 2023
38 checks passed
@DMRobertson DMRobertson deleted the dmr/ratelimit branch October 6, 2023 17:31
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.

2 participants