Skip to content

Make room upgrades faster for rooms with many bans #18574

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

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

erikjohnston
Copy link
Member

We do this by a) not pulling out all membership events, and b) batch inserting bans.

One blocking concern is that this bypasses the update_membership function, which otherwise all other membership events go via. In this case it's fine (having audited what it is doing), but I'm hesitant to set the precedent of bypassing it, given it has a lot of logic in there.

@erikjohnston erikjohnston marked this pull request as ready for review July 9, 2025 10:05
@erikjohnston erikjohnston requested a review from a team as a code owner July 9, 2025 10:05
Comment on lines 612 to 628
# Add any banned users to the new room
await self.event_creation_handler.create_and_send_new_client_events(
requester=requester,
room_id=new_room_id,
prev_event_id=last_event_id,
event_dicts=[
{
"type": EventTypes.Member,
"state_key": ban_event.state_key,
"room_id": new_room_id,
"sender": requester.user.to_string(),
"content": ban_event.content,
}
for ban_event in ban_events
],
ratelimit=False,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding our own new create_and_send_new_client_events(...) method, can we just add all of the bans to _send_events_for_new_room(...) initial_state?

It looks like it also makes its way to handle_new_client_event with bulk events like what create_and_send_new_client_events does.

Comment on lines +1526 to +1528
This supports sending membership events in very limited circumstances
(namely that the event is valid as is and doesn't need federation
requests or anything). Callers should prefer to use `update_membership`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like we should better clarify that general state events are just fine.

"sender": requester.user.to_string(),
"content": ban_event.content,
}
for ban_event in ban_events
Copy link
Contributor

@MadLittleMods MadLittleMods Jul 16, 2025

Choose a reason for hiding this comment

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

Is there a maximum number of events we should be calling with at a time?

We could use batch_iter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants