Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
invites: Don't hold the excessive FOR UPDATE lock on the realm row.
Mateusz Mandera47a3cc6fea4d
diff --git a/zerver/actions/invites.py b/zerver/actions/invites.pyindex 018abbbd469..abda3862df9 100644--- a/zerver/actions/invites.py+++ b/zerver/actions/invites.py@@ -201,7 +201,7 @@ def do_invite_users(num_invites = len(invitee_emails)# Lock the realm, since we need to not race with other invitations- realm = Realm.objects.select_for_update().get(id=user_profile.realm_id)+ realm = Realm.objects.select_for_update(no_key=True).get(id=user_profile.realm_id)check_invite_limit(realm, num_invites)if settings.BILLING_ENABLED:@@ -515,7 +515,7 @@ def do_send_user_invite_email() -> None:# Take a lock on the realm, so we can check for invitation limits without racesrealm_id = assert_is_not_none(prereg_user.realm_id)- realm = Realm.objects.select_for_update().get(id=realm_id)+ realm = Realm.objects.select_for_update(no_key=True).get(id=realm_id)check_invite_limit(realm, 1)referrer = assert_is_not_none(prereg_user.referred_by)