Skip to content
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

perf: Use more performant way to obtain and check the email as a login name with token login #41927

Merged
merged 3 commits into from
Dec 5, 2023

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Nov 30, 2023

UserManager::getByEmail is slow on large userbases so we should avoid it where possible.

  • When logging in with a token we first try to verify against the login name passed but then do a second attempt using the email address. As we already know the user id that we need to look up the email for we can use the stored uid from the token and compare the email instead of searching by mail
  • Revert change to always use an sql cast that was a behavioral change from 8bbdd9e between 24 and 25
  • Add a partial index to the configvalue to ensure that most email checks can use an indexed query -> Moved to perf: Add partial index on configvalue of preferences table #42022
    KEY `tmp_configvalue_index` (`configvalue`(80)),
    • OCI doesn't like that index cannot create index on expression with datatype LOB

TODO:

  • Come up with a good approach for adding a test case to avoid future regressions in performance

@juliushaertl juliushaertl requested review from nickvergessen, kesselb, a team, icewind1991, Fenn-CS and come-nc and removed request for a team November 30, 2023 15:55
@nickvergessen nickvergessen added this to the Nextcloud 29 milestone Nov 30, 2023
@juliushaertl juliushaertl marked this pull request as ready for review November 30, 2023 19:50
…n name with token login

Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl
Copy link
Member Author

@nickvergessen As discussed via chat, I split out the additional index and moved it to #42022 to not forget about that.

if (!(\count($users) === 1 && $this->login($users[0]->getUID(), $password))) {

if ($isTokenPassword) {
$dbToken = $this->tokenProvider->getToken($password);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice shortcut ;)

Copy link
Contributor

@Fenn-CS Fenn-CS left a comment

Choose a reason for hiding this comment

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

So far, so good.

By the way, I think it's helpful to attach the point explanations in the pull request description in the various commit bodies.

@juliushaertl juliushaertl merged commit 6c52242 into master Dec 5, 2023
48 of 50 checks passed
@juliushaertl juliushaertl deleted the perf/login-with-email-token branch December 5, 2023 10:11
@juliushaertl
Copy link
Member Author

/backport to stable28

@juliushaertl
Copy link
Member Author

/backport to stable27

@juliushaertl
Copy link
Member Author

/backport to stable26

@juliushaertl
Copy link
Member Author

/backport to stable25

@Fenn-CS
Copy link
Contributor

Fenn-CS commented Dec 6, 2023

Automatic backports have failed...

@juliushaertl
Copy link
Member Author

/backport a3a343c,3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74 to stable28

@juliushaertl
Copy link
Member Author

/backport a3a343c,3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74 to stable27

@juliushaertl
Copy link
Member Author

/backport a3a343c,3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74 to stable26

@juliushaertl
Copy link
Member Author

/backport a3a343c,3cd1d74a815531c9b7ae25ebbf8e7c45fa566e74 to stable25

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.

4 participants