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

why saveNewKeyspace() locks keyspace.Id,not keyspace.Name? #8206

Open
KinWaiYuen opened this issue May 21, 2024 · 3 comments
Open

why saveNewKeyspace() locks keyspace.Id,not keyspace.Name? #8206

KinWaiYuen opened this issue May 21, 2024 · 3 comments
Labels
type/question The issue belongs to a question.

Comments

@KinWaiYuen
Copy link

https://github.com/tikv/pd/blob/2fabb74157938ced112b1d768cb8d4b995653275/pkg/keyspace/keyspace.go#L271C2-L271C36

if several clients call CreateKeyspace, function saveNewKeyspace locks by Id which is created by manager.allocID(), etcd transaction failed, conflicted and rolled back error may be happened as Ids are allocated saperately

Copy link
Contributor

ti-chi-bot bot commented May 21, 2024

There are no type labels on this issue. Please add an appropriate label by using the following command:

  • /type <type-name>

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot added the needs-type Indicates an issue requires a type label. label May 21, 2024
@HuSharp
Copy link
Member

HuSharp commented May 22, 2024

@AmoebaProtozoa Hi, can you help to provide an answer to this question? :)

@AmoebaProtozoa
Copy link
Contributor

It mostly comes down to uniqueness and consistency.

For uniqueness, the keyspaceID is system generated and guaranteed to be unique and immutable across a keyspace's life cycle. Latching it to user provided name seems kinda risky, especially if we were to implement keyspace renaming/aliasing in the future.
For consistency, all other keyspace operations uses ID as lock, so the saveNewKeyspace() follows suite.

@rleungx rleungx added type/question The issue belongs to a question. and removed needs-type Indicates an issue requires a type label. labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question The issue belongs to a question.
Projects
Status: Need Triage
Development

No branches or pull requests

4 participants