Skip to content

Modify user or privilege will consume a significant amount of time and resources in million users scenario #55563

@lilinghai

Description

@lilinghai

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Create 1 million databases with 2 tables per database.
  2. Create 2 users for each schema and grant privileges on the schema to the users.

From the monitoring of TiDB, it can be observed that the QPS for creating users and granting permissions is continuously declining. When the number of users reaches 200,000, the QPS is nearly 1.
TiDB maintains a full set of user and permission information in memory. When there are changes to users or permissions (triggered by statements such as create/alter user, grant, etc.), TiDB calls the NotifyUpdatePrivilege function which loads the full user and permission information from TiKV to refresh the cache. As the user information increases, this operation will become increasingly time-consuming and resource-intensive. Actual tests show CPU resource consumption at over 80%, and Golang GC causes memory fluctuations exceeding 10GB.

image
image
image

2. What did you expect to see? (Required)

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

master

Metadata

Metadata

Assignees

Labels

affects-8.5This bug affects the 8.5.x(LTS) versions.sig/sql-infraSIG: SQL Infratype/enhancementThe issue or PR belongs to an enhancement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions