-
Notifications
You must be signed in to change notification settings - Fork 223
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
Fix a race when registering via email 3pid #16827
base: develop
Are you sure you want to change the base?
Conversation
@@ -506,6 +509,23 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: | |||
"An access token should not be provided on requests to /register (except if type is m.login.application_service)", | |||
) | |||
|
|||
# Take a global lock when doing user registration to avoid races, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am only protecting normal user registration with the lock because I think _do_appservice_registration
and _do_guest_registration
are safe but I am not sure to be honest, especially for the appservice one.
Out of safety we may protect the whole code in on_POST
, opinions welcome.
c2cfa8b
to
ea74288
Compare
Failing tests should turn to green once #16840 is merged. |
When a lot of locks are waiting for a single lock, notifying all locks independently with `call_later` on each release is really costly and incurs some kind of async contention, where the CPU is spinning a lot for not much. The included test is taking around 30s before the change, and 0.5s after. It was found following failing tests with #16827.
ea74288
to
027b4af
Compare
When hitting the race, 2 different users are created for an unique 3pid email.
Performance impact should be fairly minimal since we usually don't register a new user 10 times per second, unlike sending messages.
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)