uaa icon indicating copy to clipboard operation
uaa copied to clipboard

Excessive database load retrieving users when using MySQL with millions of users

Open swalchemist opened this issue 1 year ago • 3 comments

What version of UAA are you running?

The problem was found after upgrading from 77.1.0 to 77.3.0.

How are you deploying the UAA?

I am deploying the UAA as part of a commercial Cloud Foundry distribution.

What did you do?

A customer has millions of users in a MySQL database in production. We're getting queries like this that are taking more than 10 minutes, and they're stacking up and bogging down the database, causing CF commands to time out. They originated from calls to cf's /v3/users endpoint.

select count(*) from users u join identity_provider idp on u.origin = idp.origin_key and u.identity_zone_id = idp.identity_zone_id where idp.active is true and (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((LOWER(u.id) = LOWER('...id here...') OR LOWER(u.id) [...]

This caused an outage, so they rolled UAA back to 77.1.0 and saw the database load return to normal. They don't have any issues in their testing environment that only has a few thousands of users.

We see that LOWER(u.id) is indexed for postgres, but we don't create an index for mysql.

swalchemist avatar Apr 28 '24 03:04 swalchemist

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/187511412

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar Apr 28 '24 03:04 cf-gitbot

@swalchemist @bruce-ricard @Tallicia FYI, still you should think about the UAA option database.caseinsensitive. If a MYSQL landscape has set database.caseinsensitive=false, then this still can happen because for MYSQL you dont have the needed indexes

For postgresql this parameter cannot be used , but for MYSQL it can be used. See database.caseinsensitive

strehle avatar May 02 '24 15:05 strehle

@Tallicia Please decide whether you want to keep this open after PR #2859.

torsten-sap avatar May 10 '24 07:05 torsten-sap

@torsten-sap, let's close this issue, as the original reported issue has been resolved now.

hsinn0 avatar Jun 10 '24 18:06 hsinn0