Limit concurrent AS joins (#11996)
Initially introduced in matrix-org-hotfixes by e5537cf
(and tweaked by later commits).
Fixes #11995
See also #4826
This commit is contained in:
parent
2b5643b3af
commit
130fd45393
|
@ -0,0 +1 @@
|
||||||
|
Limit concurrent joins from applications services.
|
|
@ -82,6 +82,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
||||||
self.event_auth_handler = hs.get_event_auth_handler()
|
self.event_auth_handler = hs.get_event_auth_handler()
|
||||||
|
|
||||||
self.member_linearizer: Linearizer = Linearizer(name="member")
|
self.member_linearizer: Linearizer = Linearizer(name="member")
|
||||||
|
self.member_as_limiter = Linearizer(max_count=10, name="member_as_limiter")
|
||||||
|
|
||||||
self.clock = hs.get_clock()
|
self.clock = hs.get_clock()
|
||||||
self.spam_checker = hs.get_spam_checker()
|
self.spam_checker = hs.get_spam_checker()
|
||||||
|
@ -500,25 +501,32 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
|
||||||
|
|
||||||
key = (room_id,)
|
key = (room_id,)
|
||||||
|
|
||||||
with (await self.member_linearizer.queue(key)):
|
as_id = object()
|
||||||
result = await self.update_membership_locked(
|
if requester.app_service:
|
||||||
requester,
|
as_id = requester.app_service.id
|
||||||
target,
|
|
||||||
room_id,
|
# We first linearise by the application service (to try to limit concurrent joins
|
||||||
action,
|
# by application services), and then by room ID.
|
||||||
txn_id=txn_id,
|
with (await self.member_as_limiter.queue(as_id)):
|
||||||
remote_room_hosts=remote_room_hosts,
|
with (await self.member_linearizer.queue(key)):
|
||||||
third_party_signed=third_party_signed,
|
result = await self.update_membership_locked(
|
||||||
ratelimit=ratelimit,
|
requester,
|
||||||
content=content,
|
target,
|
||||||
new_room=new_room,
|
room_id,
|
||||||
require_consent=require_consent,
|
action,
|
||||||
outlier=outlier,
|
txn_id=txn_id,
|
||||||
historical=historical,
|
remote_room_hosts=remote_room_hosts,
|
||||||
allow_no_prev_events=allow_no_prev_events,
|
third_party_signed=third_party_signed,
|
||||||
prev_event_ids=prev_event_ids,
|
ratelimit=ratelimit,
|
||||||
auth_event_ids=auth_event_ids,
|
content=content,
|
||||||
)
|
new_room=new_room,
|
||||||
|
require_consent=require_consent,
|
||||||
|
outlier=outlier,
|
||||||
|
historical=historical,
|
||||||
|
allow_no_prev_events=allow_no_prev_events,
|
||||||
|
prev_event_ids=prev_event_ids,
|
||||||
|
auth_event_ids=auth_event_ids,
|
||||||
|
)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue